(t *testing.T)
| 222 | } |
| 223 | |
| 224 | func TestSearch_JSONFormat(t *testing.T) { |
| 225 | resetSearchFlags() |
| 226 | |
| 227 | tasks := []*model.Task{ |
| 228 | {ID: "001", Title: "Auth system", Status: model.StatusPending, Priority: model.PriorityHigh, FilePath: "tasks/001.md", Body: "JWT authentication"}, |
| 229 | } |
| 230 | |
| 231 | output, err := captureSearchOutput(t, tasks, "authentication", "json") |
| 232 | if err != nil { |
| 233 | t.Fatalf("unexpected error: %v", err) |
| 234 | } |
| 235 | |
| 236 | var parsed []search.Result |
| 237 | if err := json.Unmarshal([]byte(output), &parsed); err != nil { |
| 238 | t.Fatalf("failed to parse JSON output: %v\noutput: %s", err, output) |
| 239 | } |
| 240 | |
| 241 | if len(parsed) != 1 { |
| 242 | t.Fatalf("expected 1 result in JSON, got %d", len(parsed)) |
| 243 | } |
| 244 | if parsed[0].ID != "001" { |
| 245 | t.Errorf("expected id '001', got %s", parsed[0].ID) |
| 246 | } |
| 247 | if parsed[0].MatchLocation != "body" { |
| 248 | t.Errorf("expected match_location 'body', got %s", parsed[0].MatchLocation) |
| 249 | } |
| 250 | if parsed[0].Snippet == "" { |
| 251 | t.Error("expected non-empty snippet") |
| 252 | } |
| 253 | if parsed[0].Priority != "high" { |
| 254 | t.Errorf("expected priority 'high', got %s", parsed[0].Priority) |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | func TestSearch_YAMLFormat(t *testing.T) { |
| 259 | resetSearchFlags() |
nothing calls this directly
no test coverage detected