(t *testing.T)
| 372 | } |
| 373 | |
| 374 | func TestHandleStats(t *testing.T) { |
| 375 | dir := createTestTaskDir(t) |
| 376 | dp := NewDataProvider(dir, false) |
| 377 | |
| 378 | req := httptest.NewRequest(http.MethodGet, "/api/stats", nil) |
| 379 | rec := httptest.NewRecorder() |
| 380 | |
| 381 | handleStats(dp)(rec, req) |
| 382 | |
| 383 | if rec.Code != http.StatusOK { |
| 384 | t.Fatalf("expected 200, got %d", rec.Code) |
| 385 | } |
| 386 | |
| 387 | var m metrics.Metrics |
| 388 | if err := json.Unmarshal(rec.Body.Bytes(), &m); err != nil { |
| 389 | t.Fatalf("invalid JSON: %v", err) |
| 390 | } |
| 391 | |
| 392 | if m.TotalTasks != 2 { |
| 393 | t.Fatalf("expected 2 total tasks, got %d", m.TotalTasks) |
| 394 | } |
| 395 | |
| 396 | // Verify tags are included (test fixtures have "setup" and "core") |
| 397 | if len(m.TagsByCount) != 2 { |
| 398 | t.Fatalf("expected 2 tags, got %d", len(m.TagsByCount)) |
| 399 | } |
| 400 | // Both have count 1, so alphabetical: core first, setup second |
| 401 | if m.TagsByCount[0].Tag != "core" { |
| 402 | t.Errorf("expected first tag 'core', got %q", m.TagsByCount[0].Tag) |
| 403 | } |
| 404 | if m.TagsByCount[1].Tag != "setup" { |
| 405 | t.Errorf("expected second tag 'setup', got %q", m.TagsByCount[1].Tag) |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | func TestHandleValidate(t *testing.T) { |
| 410 | dir := createTestTaskDir(t) |
nothing calls this directly
no test coverage detected