(t *testing.T)
| 469 | } |
| 470 | |
| 471 | func 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 | |
| 511 | func TestFilterTasksByScope(t *testing.T) { |
| 512 | tasks := []*model.Task{ |
nothing calls this directly
no test coverage detected