fix: make tests pass on macOS CI runners

- Resolve symlinks in temp dir paths (macOS /var -> /private/var)
- Pre-create non-empty community dir to ensure clone fails reliably
  regardless of network access on CI runners

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christopher Allen Lane
2026-02-14 21:05:16 -05:00
parent 2a19755804
commit b604027205
2 changed files with 22 additions and 0 deletions

View File

@@ -39,6 +39,12 @@ func TestConfigLocalCheatpath(t *testing.T) {
}
defer os.RemoveAll(tempDir)
// Resolve symlinks in temp dir path (macOS /var -> /private/var)
tempDir, err = filepath.EvalSymlinks(tempDir)
if err != nil {
t.Fatalf("failed to resolve temp dir symlinks: %v", err)
}
// Save current working directory
oldCwd, err := os.Getwd()
if err != nil {
@@ -106,6 +112,12 @@ func TestConfigSymlinkResolution(t *testing.T) {
}
defer os.RemoveAll(tempDir)
// Resolve symlinks in temp dir path (macOS /var -> /private/var)
tempDir, err = filepath.EvalSymlinks(tempDir)
if err != nil {
t.Fatalf("failed to resolve temp dir symlinks: %v", err)
}
// Create target directory
targetDir := filepath.Join(tempDir, "target")
err = os.Mkdir(targetDir, 0755)

View File

@@ -78,6 +78,16 @@ cheatpaths:
},
}
// Pre-create a non-empty community dir so PlainClone fails reliably
// (otherwise, on CI runners with network access, the clone succeeds)
cloneBlocker := filepath.Join(tempDir, "conf2", "cheatsheets", "community")
if err := os.MkdirAll(cloneBlocker, 0755); err != nil {
t.Fatalf("failed to create clone blocker dir: %v", err)
}
if err := os.WriteFile(filepath.Join(cloneBlocker, ".gitkeep"), []byte(""), 0644); err != nil {
t.Fatalf("failed to write clone blocker file: %v", err)
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Create stdin pipe