| 8 | ) |
| 9 | |
| 10 | func TestSpecCommand_WritesToDirectory(t *testing.T) { |
| 11 | tmpDir := t.TempDir() |
| 12 | |
| 13 | specForce = false |
| 14 | specStdout = false |
| 15 | taskDir = tmpDir |
| 16 | |
| 17 | err := runSpec(specCmd, []string{}) |
| 18 | if err != nil { |
| 19 | t.Fatalf("unexpected error: %v", err) |
| 20 | } |
| 21 | |
| 22 | outputPath := filepath.Join(tmpDir, specFilename) |
| 23 | content, err := os.ReadFile(outputPath) |
| 24 | if err != nil { |
| 25 | t.Fatalf("failed to read created file: %v", err) |
| 26 | } |
| 27 | |
| 28 | if !bytes.Equal(content, specTemplate) { |
| 29 | t.Error("written content does not match embedded spec") |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func TestSpecCommand_RefusesOverwriteWithoutForce(t *testing.T) { |
| 34 | tmpDir := t.TempDir() |