MCPcopy Create free account
hub / github.com/driangle/taskmd / TestHandleBoard_WithProject

Function TestHandleBoard_WithProject

apps/cli/internal/web/handlers_test.go:1497–1537  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1495}
1496
1497func TestHandleBoard_WithProject(t *testing.T) {
1498 projectDir := createProjectTaskDir(t)
1499 defaultDir := createTestTaskDir(t)
1500
1501 defaultDP := NewDataProvider(defaultDir, false)
1502 defaultPhases := []PhaseInfo{{ID: "default-phase"}}
1503
1504 resolver := NewProjectResolver(func(id string) (string, []PhaseInfo, error) {
1505 if id == "proj-a" {
1506 return projectDir, []PhaseInfo{{ID: "proj-phase"}}, nil
1507 }
1508 return "", nil, ErrProjectNotFound
1509 }, false)
1510
1511 handler := setupProjectMiddleware(resolver, handleBoard(defaultDP, defaultPhases))
1512
1513 req := httptest.NewRequest(http.MethodGet, "/api/board?project=proj-a", nil)
1514 rec := httptest.NewRecorder()
1515 handler.ServeHTTP(rec, req)
1516
1517 if rec.Code != http.StatusOK {
1518 t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String())
1519 }
1520
1521 var result []board.JSONGroup
1522 if err := json.Unmarshal(rec.Body.Bytes(), &result); err != nil {
1523 t.Fatalf("invalid JSON: %v", err)
1524 }
1525 // Should contain project task P01, not default tasks 001/002.
1526 found := false
1527 for _, g := range result {
1528 for _, task := range g.Tasks {
1529 if task.ID == "P01" {
1530 found = true
1531 }
1532 }
1533 }
1534 if !found {
1535 t.Fatal("expected project task P01 in board response")
1536 }
1537}

Callers

nothing calls this directly

Calls 7

createProjectTaskDirFunction · 0.85
createTestTaskDirFunction · 0.85
NewDataProviderFunction · 0.85
NewProjectResolverFunction · 0.85
setupProjectMiddlewareFunction · 0.85
handleBoardFunction · 0.85
ServeHTTPMethod · 0.80

Tested by

no test coverage detected