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

Function TestContext_JSON

apps/cli/internal/cli/context_test.go:274–316  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

272}
273
274func TestContext_JSON(t *testing.T) {
275 tmpDir := createContextTestFiles(t)
276 resetContextFlags()
277 taskDir = tmpDir
278 setupTestConfig(t, tmpDir)
279
280 ctxTaskID = "003"
281 ctxFormat = "json"
282 output, err := captureContextOutput(t)
283 if err != nil {
284 t.Fatalf("unexpected error: %v", err)
285 }
286
287 var result taskcontext.Result
288 if err := json.Unmarshal([]byte(output), &result); err != nil {
289 t.Fatalf("failed to parse JSON: %v\nOutput: %s", err, output)
290 }
291
292 if result.TaskID != "003" {
293 t.Errorf("expected task_id 003, got %s", result.TaskID)
294 }
295 if len(result.Files) < 2 {
296 t.Errorf("expected at least 2 files, got %d", len(result.Files))
297 }
298
299 // Check source tagging
300 foundScope := false
301 foundExplicit := false
302 for _, f := range result.Files {
303 if strings.HasPrefix(f.Source, "scope:") {
304 foundScope = true
305 }
306 if f.Source == "explicit" {
307 foundExplicit = true
308 }
309 }
310 if !foundScope {
311 t.Error("expected at least one scope-sourced file")
312 }
313 if !foundExplicit {
314 t.Error("expected at least one explicit-sourced file")
315 }
316}
317
318func TestContext_YAML(t *testing.T) {
319 tmpDir := createContextTestFiles(t)

Callers

nothing calls this directly

Calls 5

createContextTestFilesFunction · 0.85
resetContextFlagsFunction · 0.85
setupTestConfigFunction · 0.85
captureContextOutputFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected