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

Function TestCanonicalPathResolvesSymlink

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

Source from the content-addressed store, hash-verified

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