MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestCanonicalPathResolvesSymlink

Function TestCanonicalPathResolvesSymlink

internal/pathutil/path_test.go:36–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestCanonicalPathResolvesSymlink(t *testing.T) {
37 realDir := t.TempDir()
38 linkParent := t.TempDir()
39 linkPath := filepath.Join(linkParent, "repo-link")
40 if err := os.Symlink(realDir, linkPath); err != nil {
41 t.Skipf("symlink not supported: %v", err)
42 }
43
44 got, err := CanonicalPath(linkPath)
45 if err != nil {
46 t.Fatalf("CanonicalPath: %v", err)
47 }
48 want, err := filepath.EvalSymlinks(realDir)
49 if err != nil {
50 t.Fatalf("EvalSymlinks realDir: %v", err)
51 }
52 if got != want {
53 t.Fatalf("CanonicalPath(%q) = %q, want %q", linkPath, got, want)
54 }
55}
56
57func TestCanonicalPath_NonExistentPath(t *testing.T) {
58 _, err := CanonicalPath(filepath.Join(t.TempDir(), "does", "not", "exist"))

Callers

nothing calls this directly

Calls 1

CanonicalPathFunction · 0.85

Tested by

no test coverage detected