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

Function TestStatus_JSONFormat

apps/cli/internal/cli/status_test.go:171–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

169}
170
171func TestStatus_JSONFormat(t *testing.T) {
172 tmpDir := createStatusTestFiles(t)
173 resetStatusFlags()
174 taskDir = tmpDir
175 statusFormat = "json"
176
177 output := captureStatusOutput(t, "002")
178
179 var result statusOutput
180 if err := json.Unmarshal([]byte(output), &result); err != nil {
181 t.Fatalf("Failed to parse JSON output: %v\nOutput: %s", err, output)
182 }
183
184 if result.ID != "002" {
185 t.Errorf("Expected ID '002', got %q", result.ID)
186 }
187 if result.Title != "Implement authentication" {
188 t.Errorf("Expected title 'Implement authentication', got %q", result.Title)
189 }
190 if result.Status != "in-progress" {
191 t.Errorf("Expected status 'in-progress', got %q", result.Status)
192 }
193 if result.Priority != "critical" {
194 t.Errorf("Expected priority 'critical', got %q", result.Priority)
195 }
196 if result.Effort != "large" {
197 t.Errorf("Expected effort 'large', got %q", result.Effort)
198 }
199 if result.Owner != "alice" {
200 t.Errorf("Expected owner 'alice', got %q", result.Owner)
201 }
202 if len(result.Dependencies) != 1 || result.Dependencies[0] != "001" {
203 t.Errorf("Expected dependencies [001], got %v", result.Dependencies)
204 }
205
206 // Verify no content/body field in JSON
207 var raw map[string]any
208 if err := json.Unmarshal([]byte(output), &raw); err != nil {
209 t.Fatalf("Failed to parse raw JSON: %v", err)
210 }
211 if _, ok := raw["content"]; ok {
212 t.Error("JSON output should not contain 'content' key")
213 }
214 if _, ok := raw["body"]; ok {
215 t.Error("JSON output should not contain 'body' key")
216 }
217}
218
219func TestStatus_YAMLFormat(t *testing.T) {
220 tmpDir := createStatusTestFiles(t)

Callers

nothing calls this directly

Calls 4

createStatusTestFilesFunction · 0.85
resetStatusFlagsFunction · 0.85
captureStatusOutputFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected