| 59 | } |
| 60 | |
| 61 | func TestSpecCommand_OverwritesWithForce(t *testing.T) { |
| 62 | tmpDir := t.TempDir() |
| 63 | |
| 64 | existingPath := filepath.Join(tmpDir, specFilename) |
| 65 | if err := os.WriteFile(existingPath, []byte("old content"), 0644); err != nil { |
| 66 | t.Fatalf("failed to create existing file: %v", err) |
| 67 | } |
| 68 | |
| 69 | specForce = true |
| 70 | specStdout = false |
| 71 | taskDir = tmpDir |
| 72 | |
| 73 | err := runSpec(specCmd, []string{}) |
| 74 | if err != nil { |
| 75 | t.Fatalf("unexpected error with --force: %v", err) |
| 76 | } |
| 77 | |
| 78 | content, err := os.ReadFile(existingPath) |
| 79 | if err != nil { |
| 80 | t.Fatalf("failed to read file: %v", err) |
| 81 | } |
| 82 | |
| 83 | if !bytes.Equal(content, specTemplate) { |
| 84 | t.Error("file should have been overwritten with spec content") |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | func TestSpecCommand_StdoutPrintsWithoutCreatingFile(t *testing.T) { |
| 89 | tmpDir := t.TempDir() |