TestFindLocalCheatpathInParent tests walking up to a parent directory
(t *testing.T)
| 35 | |
| 36 | // TestFindLocalCheatpathInParent tests walking up to a parent directory |
| 37 | func TestFindLocalCheatpathInParent(t *testing.T) { |
| 38 | tempDir, err := os.MkdirTemp("", "cheat-test-*") |
| 39 | if err != nil { |
| 40 | t.Fatalf("failed to create temp dir: %v", err) |
| 41 | } |
| 42 | defer os.RemoveAll(tempDir) |
| 43 | |
| 44 | cheatDir := filepath.Join(tempDir, ".cheat") |
| 45 | if err := os.Mkdir(cheatDir, 0755); err != nil { |
| 46 | t.Fatalf("failed to create .cheat dir: %v", err) |
| 47 | } |
| 48 | |
| 49 | subDir := filepath.Join(tempDir, "sub") |
| 50 | if err := os.Mkdir(subDir, 0755); err != nil { |
| 51 | t.Fatalf("failed to create sub dir: %v", err) |
| 52 | } |
| 53 | |
| 54 | result := findLocalCheatpath(subDir) |
| 55 | if result != cheatDir { |
| 56 | t.Errorf("expected %s, got %s", cheatDir, result) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // TestFindLocalCheatpathInGrandparent tests walking up multiple levels |
| 61 | func TestFindLocalCheatpathInGrandparent(t *testing.T) { |
nothing calls this directly
no test coverage detected