(t *testing.T)
| 359 | } |
| 360 | |
| 361 | func TestInferGitRepoRoot_SymlinkChain(t *testing.T) { |
| 362 | tempDir, _ := setupTestRepository(t) |
| 363 | |
| 364 | // Create a separate temp directory for symlinks |
| 365 | symlinkBase := t.TempDir() |
| 366 | symlink1 := filepath.Join(symlinkBase, "symlink1") |
| 367 | symlink2 := filepath.Join(symlinkBase, "symlink2") |
| 368 | |
| 369 | err := os.Symlink(tempDir, symlink1) |
| 370 | require.NoError(t, err, "failed to create first symlink") |
| 371 | |
| 372 | err = os.Symlink(symlink1, symlink2) |
| 373 | require.NoError(t, err, "failed to create second symlink") |
| 374 | |
| 375 | root, err := InferGitRepoRoot(symlink2) |
| 376 | require.NoError(t, err, "InferGitRepoRoot failed on symlink chain") |
| 377 | |
| 378 | // Get the canonical path of the expected repo root |
| 379 | expectedRoot, err := filepath.EvalSymlinks(tempDir) |
| 380 | require.NoError(t, err, "failed to resolve symlinks in expected root") |
| 381 | |
| 382 | // Get the canonical path of the actual result |
| 383 | actualRoot, err := filepath.EvalSymlinks(root) |
| 384 | require.NoError(t, err, "failed to resolve symlinks in actual root") |
| 385 | |
| 386 | require.Equal(t, expectedRoot, actualRoot, "repo root should match after symlink resolution") |
| 387 | } |
| 388 | |
| 389 | func TestInferGitRepoRoot_SymlinkToNonRepo(t *testing.T) { |
| 390 | nonRepoDir := t.TempDir() |
nothing calls this directly
no test coverage detected