(t *testing.T)
| 44 | } |
| 45 | |
| 46 | func TestFindAllDuplicateIDs(t *testing.T) { |
| 47 | t.Run("finds duplicates", func(t *testing.T) { |
| 48 | tasks := []*model.Task{ |
| 49 | {ID: "001", FilePath: "a/001.md"}, |
| 50 | {ID: "002", FilePath: "a/002.md"}, |
| 51 | {ID: "001", FilePath: "b/001.md"}, |
| 52 | {ID: "003", FilePath: "a/003.md"}, |
| 53 | {ID: "003", FilePath: "b/003.md"}, |
| 54 | } |
| 55 | |
| 56 | dupes := findAllDuplicateIDs(tasks) |
| 57 | if len(dupes) != 2 { |
| 58 | t.Fatalf("expected 2 duplicate IDs, got %d", len(dupes)) |
| 59 | } |
| 60 | if len(dupes["001"]) != 2 { |
| 61 | t.Errorf("expected 2 paths for ID 001, got %d", len(dupes["001"])) |
| 62 | } |
| 63 | if len(dupes["003"]) != 2 { |
| 64 | t.Errorf("expected 2 paths for ID 003, got %d", len(dupes["003"])) |
| 65 | } |
| 66 | }) |
| 67 | |
| 68 | t.Run("returns empty when no duplicates", func(t *testing.T) { |
| 69 | tasks := []*model.Task{ |
| 70 | {ID: "001", FilePath: "a/001.md"}, |
| 71 | {ID: "002", FilePath: "a/002.md"}, |
| 72 | } |
| 73 | |
| 74 | dupes := findAllDuplicateIDs(tasks) |
| 75 | if len(dupes) != 0 { |
| 76 | t.Fatalf("expected no duplicates, got %d", len(dupes)) |
| 77 | } |
| 78 | }) |
| 79 | } |
| 80 | |
| 81 | func TestWarnDuplicateIDs(t *testing.T) { |
| 82 | t.Run("prints warning for duplicates", func(t *testing.T) { |
nothing calls this directly
no test coverage detected