(t *testing.T)
| 80 | } |
| 81 | |
| 82 | func TestNextID_EmptyDirectory(t *testing.T) { |
| 83 | resetNextIDFlags() |
| 84 | |
| 85 | tmpDir := t.TempDir() |
| 86 | |
| 87 | oldStdout := os.Stdout |
| 88 | r, w, _ := os.Pipe() |
| 89 | os.Stdout = w |
| 90 | |
| 91 | err := runNextID(nextIDCmd, []string{tmpDir}) |
| 92 | |
| 93 | w.Close() |
| 94 | os.Stdout = oldStdout |
| 95 | |
| 96 | if err != nil { |
| 97 | t.Fatalf("unexpected error: %v", err) |
| 98 | } |
| 99 | |
| 100 | var buf bytes.Buffer |
| 101 | buf.ReadFrom(r) |
| 102 | output := strings.TrimSpace(buf.String()) |
| 103 | |
| 104 | if output != "001" { |
| 105 | t.Errorf("expected 001, got %q", output) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestNextID_PrefixedIDs(t *testing.T) { |
| 110 | resetNextIDFlags() |
nothing calls this directly
no test coverage detected