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

Function TestRunStats_JSONOutput

apps/cli/internal/cli/stats_test.go:95–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestRunStats_JSONOutput(t *testing.T) {
96 tmpDir := createStatsTestFiles(t)
97 resetStatsFlags()
98 statsFormat = "json"
99
100 output, err := captureStatsOutput(t, []string{tmpDir})
101 if err != nil {
102 t.Fatalf("runStats failed: %v", err)
103 }
104
105 var m metrics.Metrics
106 if err := json.Unmarshal([]byte(output), &m); err != nil {
107 t.Fatalf("failed to parse JSON: %v\noutput: %s", err, output)
108 }
109
110 if m.TotalTasks != 3 {
111 t.Errorf("total_tasks = %d, want 3", m.TotalTasks)
112 }
113 if m.TasksByStatus[model.StatusPending] != 2 {
114 t.Errorf("tasks_by_status[pending] = %d, want 2", m.TasksByStatus[model.StatusPending])
115 }
116 if m.TasksByStatus[model.StatusCompleted] != 1 {
117 t.Errorf("tasks_by_status[completed] = %d, want 1", m.TasksByStatus[model.StatusCompleted])
118 }
119}
120
121func TestRunStats_YAMLOutput(t *testing.T) {
122 tmpDir := createStatsTestFiles(t)

Callers

nothing calls this directly

Calls 3

createStatsTestFilesFunction · 0.85
resetStatsFlagsFunction · 0.85
captureStatsOutputFunction · 0.85

Tested by

no test coverage detected