MCPcopy
hub / github.com/cheat/cheat / TestFindLocalCheatpathSymlink

Function TestFindLocalCheatpathSymlink

internal/config/config_test.go:154–173  ·  view source on GitHub ↗

TestFindLocalCheatpathSymlink tests that a .cheat symlink to a directory is found

(t *testing.T)

Source from the content-addressed store, hash-verified

152
153// TestFindLocalCheatpathSymlink tests that a .cheat symlink to a directory is found
154func 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

Callers

nothing calls this directly

Calls 1

findLocalCheatpathFunction · 0.85

Tested by

no test coverage detected