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

Function TestListCommand_LimitJSONOutput

apps/cli/internal/cli/list_test.go:471–509  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

469}
470
471func TestListCommand_LimitJSONOutput(t *testing.T) {
472 resetListFlags()
473
474 tasks := []*model.Task{
475 {ID: "001", Title: "First", Status: model.StatusPending},
476 {ID: "002", Title: "Second", Status: model.StatusPending},
477 {ID: "003", Title: "Third", Status: model.StatusPending},
478 }
479
480 limited := tasks[:2]
481
482 oldStdout := os.Stdout
483 r, w, _ := os.Pipe()
484 os.Stdout = w
485
486 err := outputJSON(limited)
487 if err != nil {
488 w.Close()
489 os.Stdout = oldStdout
490 t.Fatalf("outputJSON failed: %v", err)
491 }
492
493 w.Close()
494 os.Stdout = oldStdout
495
496 var buf bytes.Buffer
497 buf.ReadFrom(r)
498 output := buf.String()
499
500 if !strings.Contains(output, "001") {
501 t.Error("Expected task 001 in JSON output")
502 }
503 if !strings.Contains(output, "002") {
504 t.Error("Expected task 002 in JSON output")
505 }
506 if strings.Contains(output, "003") {
507 t.Error("Task 003 should not appear in limited JSON output")
508 }
509}
510
511func TestFilterTasksByScope(t *testing.T) {
512 tasks := []*model.Task{

Callers

nothing calls this directly

Calls 3

resetListFlagsFunction · 0.85
outputJSONFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected