TestFindLocalCheatpathSymlink tests that a .cheat symlink to a directory is found
(t *testing.T)
| 152 | |
| 153 | // TestFindLocalCheatpathSymlink tests that a .cheat symlink to a directory is found |
| 154 | func TestFindLocalCheatpathSymlink(t *testing.T) { |
| 155 | tempDir := t.TempDir() |
| 156 | |
| 157 | // Create the real directory |
| 158 | realDir := filepath.Join(tempDir, "real-cheat") |
| 159 | if err := os.Mkdir(realDir, 0755); err != nil { |
| 160 | t.Fatalf("failed to create real dir: %v", err) |
| 161 | } |
| 162 | |
| 163 | // Symlink .cheat -> real-cheat |
| 164 | cheatLink := filepath.Join(tempDir, ".cheat") |
| 165 | if err := os.Symlink(realDir, cheatLink); err != nil { |
| 166 | t.Fatalf("failed to create symlink: %v", err) |
| 167 | } |
| 168 | |
| 169 | result := findLocalCheatpath(tempDir) |
| 170 | if result != cheatLink { |
| 171 | t.Errorf("expected %s, got %s", cheatLink, result) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | // TestFindLocalCheatpathSymlinkInAncestor tests discovery through a symlinked |
| 176 | // ancestor directory. When the cwd is reached via a symlink, filepath.Dir |
nothing calls this directly
no test coverage detected