MCPcopy
hub / github.com/cheat/cheat / TestFindLocalCheatpathInGrandparent

Function TestFindLocalCheatpathInGrandparent

internal/config/config_test.go:61–82  ·  view source on GitHub ↗

TestFindLocalCheatpathInGrandparent tests walking up multiple levels

(t *testing.T)

Source from the content-addressed store, hash-verified

59
60// TestFindLocalCheatpathInGrandparent tests walking up multiple levels
61func 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
85func TestFindLocalCheatpathNearestWins(t *testing.T) {

Callers

nothing calls this directly

Calls 1

findLocalCheatpathFunction · 0.85

Tested by

no test coverage detected