(t *testing.T)
| 51 | } |
| 52 | |
| 53 | func TestApplyFilters(t *testing.T) { |
| 54 | tasks := []*model.Task{ |
| 55 | {ID: "001", Status: model.StatusPending, Priority: model.PriorityHigh}, |
| 56 | {ID: "002", Status: model.StatusCompleted, Priority: model.PriorityLow}, |
| 57 | {ID: "003", Status: model.StatusPending, Priority: model.PriorityMedium}, |
| 58 | {ID: "004", Status: model.StatusPending, Priority: model.PriorityHigh}, |
| 59 | } |
| 60 | |
| 61 | tests := []struct { |
| 62 | name string |
| 63 | filters []string |
| 64 | expectedLen int |
| 65 | wantErr bool |
| 66 | }{ |
| 67 | {"single filter by status", []string{"status=pending"}, 3, false}, |
| 68 | {"single filter by priority", []string{"priority=high"}, 2, false}, |
| 69 | {"multiple filters AND", []string{"status=pending", "priority=high"}, 2, false}, |
| 70 | {"no matches", []string{"status=blocked"}, 0, false}, |
| 71 | {"multiple filters no matches", []string{"status=pending", "priority=low"}, 0, false}, |
| 72 | {"invalid filter format", []string{"invalid"}, 0, true}, |
| 73 | } |
| 74 | |
| 75 | for _, tt := range tests { |
| 76 | t.Run(tt.name, func(t *testing.T) { |
| 77 | result, err := applyFilters(tasks, tt.filters) |
| 78 | if (err != nil) != tt.wantErr { |
| 79 | t.Errorf("applyFilters() error = %v, wantErr %v", err, tt.wantErr) |
| 80 | return |
| 81 | } |
| 82 | if !tt.wantErr && len(result) != tt.expectedLen { |
| 83 | t.Errorf("applyFilters() got %d tasks, want %d", len(result), tt.expectedLen) |
| 84 | } |
| 85 | }) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | func TestMatchesAllFilters(t *testing.T) { |
| 90 | task := &model.Task{ |
nothing calls this directly
no test coverage detected