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

Function TestNextID_NumericIDs

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

Source from the content-addressed store, hash-verified

28}
29
30func TestNextID_NumericIDs(t *testing.T) {
31 resetNextIDFlags()
32
33 tmpDir := createNextIDTestFiles(t, map[string]string{
34 "001-first.md": `---
35id: "001"
36title: "First task"
37status: pending
38priority: medium
39created: 2026-02-14
40---
41`,
42 "002-second.md": `---
43id: "002"
44title: "Second task"
45status: pending
46priority: medium
47created: 2026-02-14
48---
49`,
50 "005-fifth.md": `---
51id: "005"
52title: "Fifth task (gap)"
53status: pending
54priority: medium
55created: 2026-02-14
56---
57`,
58 })
59
60 oldStdout := os.Stdout
61 r, w, _ := os.Pipe()
62 os.Stdout = w
63
64 err := runNextID(nextIDCmd, []string{tmpDir})
65
66 w.Close()
67 os.Stdout = oldStdout
68
69 if err != nil {
70 t.Fatalf("unexpected error: %v", err)
71 }
72
73 var buf bytes.Buffer
74 buf.ReadFrom(r)
75 output := strings.TrimSpace(buf.String())
76
77 if output != "006" {
78 t.Errorf("expected 006, got %q", output)
79 }
80}
81
82func TestNextID_EmptyDirectory(t *testing.T) {
83 resetNextIDFlags()

Callers

nothing calls this directly

Calls 3

resetNextIDFlagsFunction · 0.85
createNextIDTestFilesFunction · 0.85
runNextIDFunction · 0.85

Tested by

no test coverage detected