(t *testing.T)
| 185 | } |
| 186 | |
| 187 | func TestAdd_JSONOutput(t *testing.T) { |
| 188 | tmpDir := t.TempDir() |
| 189 | resetAddFlags() |
| 190 | taskDir = tmpDir |
| 191 | addFormat = "json" |
| 192 | |
| 193 | output, err := captureAddOutput(t, "JSON task") |
| 194 | if err != nil { |
| 195 | t.Fatalf("unexpected error: %v", err) |
| 196 | } |
| 197 | |
| 198 | var result addResult |
| 199 | if err := json.Unmarshal([]byte(output), &result); err != nil { |
| 200 | t.Fatalf("failed to parse JSON output: %v\nOutput: %s", err, output) |
| 201 | } |
| 202 | |
| 203 | if result.ID != "001" { |
| 204 | t.Errorf("expected id 001, got %s", result.ID) |
| 205 | } |
| 206 | if result.Title != "JSON task" { |
| 207 | t.Errorf("expected title 'JSON task', got %s", result.Title) |
| 208 | } |
| 209 | if result.Status != "pending" { |
| 210 | t.Errorf("expected status pending, got %s", result.Status) |
| 211 | } |
| 212 | if result.Priority != "medium" { |
| 213 | t.Errorf("expected priority medium, got %s", result.Priority) |
| 214 | } |
| 215 | if result.FilePath == "" { |
| 216 | t.Error("expected non-empty file_path") |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func TestAdd_InvalidPriority(t *testing.T) { |
| 221 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected