MCPcopy Index your code
hub / github.com/rilldata/rill / TestInferGitRepoRoot_SymlinkChain

Function TestInferGitRepoRoot_SymlinkChain

cli/pkg/gitutil/gitcmdwrapper_test.go:361–387  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

359}
360
361func 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
389func TestInferGitRepoRoot_SymlinkToNonRepo(t *testing.T) {
390 nonRepoDir := t.TempDir()

Callers

nothing calls this directly

Calls 3

InferGitRepoRootFunction · 0.85
setupTestRepositoryFunction · 0.70
TempDirMethod · 0.65

Tested by

no test coverage detected