TestFindLocalCheatpathInGrandparent tests walking up multiple levels
(t *testing.T)
| 59 | |
| 60 | // TestFindLocalCheatpathInGrandparent tests walking up multiple levels |
| 61 | func TestFindLocalCheatpathInGrandparent(t *testing.T) { |
| 62 | tempDir, err := os.MkdirTemp("", "cheat-test-*") |
| 63 | if err != nil { |
| 64 | t.Fatalf("failed to create temp dir: %v", err) |
| 65 | } |
| 66 | defer os.RemoveAll(tempDir) |
| 67 | |
| 68 | cheatDir := filepath.Join(tempDir, ".cheat") |
| 69 | if err := os.Mkdir(cheatDir, 0755); err != nil { |
| 70 | t.Fatalf("failed to create .cheat dir: %v", err) |
| 71 | } |
| 72 | |
| 73 | deepDir := filepath.Join(tempDir, "a", "b", "c") |
| 74 | if err := os.MkdirAll(deepDir, 0755); err != nil { |
| 75 | t.Fatalf("failed to create deep dir: %v", err) |
| 76 | } |
| 77 | |
| 78 | result := findLocalCheatpath(deepDir) |
| 79 | if result != cheatDir { |
| 80 | t.Errorf("expected %s, got %s", cheatDir, result) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // TestFindLocalCheatpathNearestWins tests that the closest .cheat is returned |
| 85 | func TestFindLocalCheatpathNearestWins(t *testing.T) { |
nothing calls this directly
no test coverage detected