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

Function TestNextID_PrefixedIDs

apps/cli/internal/cli/nextid_test.go:109–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestNextID_PrefixedIDs(t *testing.T) {
110 resetNextIDFlags()
111
112 tmpDir := createNextIDTestFiles(t, map[string]string{
113 "WEB-001.md": `---
114id: "WEB-001"
115title: "Web task 1"
116status: pending
117priority: medium
118created: 2026-02-14
119---
120`,
121 "WEB-002.md": `---
122id: "WEB-002"
123title: "Web task 2"
124status: pending
125priority: medium
126created: 2026-02-14
127---
128`,
129 "WEB-003.md": `---
130id: "WEB-003"
131title: "Web task 3"
132status: pending
133priority: medium
134created: 2026-02-14
135---
136`,
137 })
138
139 oldStdout := os.Stdout
140 r, w, _ := os.Pipe()
141 os.Stdout = w
142
143 err := runNextID(nextIDCmd, []string{tmpDir})
144
145 w.Close()
146 os.Stdout = oldStdout
147
148 if err != nil {
149 t.Fatalf("unexpected error: %v", err)
150 }
151
152 var buf bytes.Buffer
153 buf.ReadFrom(r)
154 output := strings.TrimSpace(buf.String())
155
156 if output != "WEB-004" {
157 t.Errorf("expected WEB-004, got %q", output)
158 }
159}
160
161func TestNextID_JSONFormat(t *testing.T) {
162 resetNextIDFlags()

Callers

nothing calls this directly

Calls 3

resetNextIDFlagsFunction · 0.85
createNextIDTestFilesFunction · 0.85
runNextIDFunction · 0.85

Tested by

no test coverage detected