(t *testing.T)
| 508 | } |
| 509 | |
| 510 | func TestSearch_AllFlagsCombined(t *testing.T) { |
| 511 | resetSearchFlags() |
| 512 | |
| 513 | tasks := []*model.Task{ |
| 514 | {ID: "001", Title: "Bug fix auth", Status: model.StatusPending, Priority: model.PriorityLow, Body: "fix login bug"}, |
| 515 | {ID: "002", Title: "Bug fix deploy", Status: model.StatusPending, Priority: model.PriorityHigh, Body: "fix deploy bug"}, |
| 516 | {ID: "003", Title: "Bug fix cache", Status: model.StatusPending, Priority: model.PriorityCritical, Body: "fix cache bug"}, |
| 517 | {ID: "004", Title: "Bug fix API", Status: model.StatusCompleted, Priority: model.PriorityCritical, Body: "fix api bug"}, |
| 518 | } |
| 519 | |
| 520 | // Filter: only pending tasks |
| 521 | filtered, err := applyFilters(tasks, []string{"status=pending"}) |
| 522 | if err != nil { |
| 523 | t.Fatalf("unexpected filter error: %v", err) |
| 524 | } |
| 525 | |
| 526 | // Sort by priority (critical first) |
| 527 | if err := sortTasks(filtered, "priority"); err != nil { |
| 528 | t.Fatalf("unexpected sort error: %v", err) |
| 529 | } |
| 530 | |
| 531 | // Search for "bug" |
| 532 | results := search.Search(filtered, "bug") |
| 533 | |
| 534 | // Limit to 2 |
| 535 | if len(results) > 2 { |
| 536 | results = results[:2] |
| 537 | } |
| 538 | |
| 539 | if len(results) != 2 { |
| 540 | t.Fatalf("expected 2 results, got %d", len(results)) |
| 541 | } |
| 542 | // Critical pending first, then high pending |
| 543 | if results[0].ID != "003" { |
| 544 | t.Errorf("expected first result 003 (critical), got %s", results[0].ID) |
| 545 | } |
| 546 | if results[1].ID != "002" { |
| 547 | t.Errorf("expected second result 002 (high), got %s", results[1].ID) |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | func TestSearch_FilterNoMatchingTasks(t *testing.T) { |
| 552 | resetSearchFlags() |
nothing calls this directly
no test coverage detected