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

Function TestDirFlag_ListIntegration

apps/cli/internal/cli/dir_flag_test.go:45–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestDirFlag_ListIntegration(t *testing.T) {
46 tmpDir := t.TempDir()
47
48 // Create a minimal task file
49 taskContent := `---
50id: "001"
51title: "Test Task"
52status: pending
53priority: high
54---
55# Test Task
56`
57 err := os.WriteFile(filepath.Join(tmpDir, "001.md"), []byte(taskContent), 0644)
58 if err != nil {
59 t.Fatalf("failed to write test task file: %v", err)
60 }
61
62 // Save and reset flags
63 oldDir := taskDir
64 oldListFormat := listFormat
65 oldFilters := listFilters
66 oldSort := listSort
67 oldColumns := listColumns
68 defer func() {
69 taskDir = oldDir
70 listFormat = oldListFormat
71 listFilters = oldFilters
72 listSort = oldSort
73 listColumns = oldColumns
74 }()
75
76 // Use --task-dir flag (no positional arg)
77 taskDir = tmpDir
78 listFormat = "json"
79 listFilters = []string{}
80 listSort = ""
81 listColumns = "id,title,status,priority"
82
83 // Capture stdout
84 oldStdout := os.Stdout
85 r, w, _ := os.Pipe()
86 os.Stdout = w
87
88 err = runList(listCmd, []string{})
89
90 w.Close()
91 os.Stdout = oldStdout
92
93 var buf bytes.Buffer
94 buf.ReadFrom(r)
95 output := buf.String()
96
97 if err != nil {
98 t.Fatalf("runList with --dir flag failed: %v", err)
99 }
100
101 // Verify output contains the task
102 var tasks []map[string]any

Callers

nothing calls this directly

Calls 1

runListFunction · 0.85

Tested by

no test coverage detected