(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func TestNextID_NumericIDs(t *testing.T) { |
| 31 | resetNextIDFlags() |
| 32 | |
| 33 | tmpDir := createNextIDTestFiles(t, map[string]string{ |
| 34 | "001-first.md": `--- |
| 35 | id: "001" |
| 36 | title: "First task" |
| 37 | status: pending |
| 38 | priority: medium |
| 39 | created: 2026-02-14 |
| 40 | --- |
| 41 | `, |
| 42 | "002-second.md": `--- |
| 43 | id: "002" |
| 44 | title: "Second task" |
| 45 | status: pending |
| 46 | priority: medium |
| 47 | created: 2026-02-14 |
| 48 | --- |
| 49 | `, |
| 50 | "005-fifth.md": `--- |
| 51 | id: "005" |
| 52 | title: "Fifth task (gap)" |
| 53 | status: pending |
| 54 | priority: medium |
| 55 | created: 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 | |
| 82 | func TestNextID_EmptyDirectory(t *testing.T) { |
| 83 | resetNextIDFlags() |
nothing calls this directly
no test coverage detected