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

Function TestHandleTasks

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

Source from the content-addressed store, hash-verified

52}
53
54func TestHandleTasks(t *testing.T) {
55 dir := createTestTaskDir(t)
56 dp := NewDataProvider(dir, false)
57
58 req := httptest.NewRequest(http.MethodGet, "/api/tasks", nil)
59 rec := httptest.NewRecorder()
60
61 handleTasks(dp)(rec, req)
62
63 if rec.Code != http.StatusOK {
64 t.Fatalf("expected 200, got %d", rec.Code)
65 }
66
67 ct := rec.Header().Get("Content-Type")
68 if ct != "application/json" {
69 t.Fatalf("expected application/json, got %s", ct)
70 }
71
72 var tasks []map[string]any
73 if err := json.Unmarshal(rec.Body.Bytes(), &tasks); err != nil {
74 t.Fatalf("invalid JSON: %v", err)
75 }
76
77 if len(tasks) != 2 {
78 t.Fatalf("expected 2 tasks, got %d", len(tasks))
79 }
80}
81
82func TestHandleTaskByID_Success(t *testing.T) {
83 dir := createTestTaskDir(t)

Callers

nothing calls this directly

Calls 3

createTestTaskDirFunction · 0.85
NewDataProviderFunction · 0.85
handleTasksFunction · 0.85

Tested by

no test coverage detected