MCPcopy
hub / github.com/cheat/cheat / TestFindLocalCheatpathInParent

Function TestFindLocalCheatpathInParent

internal/config/config_test.go:37–58  ·  view source on GitHub ↗

TestFindLocalCheatpathInParent tests walking up to a parent directory

(t *testing.T)

Source from the content-addressed store, hash-verified

35
36// TestFindLocalCheatpathInParent tests walking up to a parent directory
37func 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
61func TestFindLocalCheatpathInGrandparent(t *testing.T) {

Callers

nothing calls this directly

Calls 1

findLocalCheatpathFunction · 0.85

Tested by

no test coverage detected