(t *testing.T)
| 87 | } |
| 88 | |
| 89 | func TestCanonicalPath_NestedSymlink(t *testing.T) { |
| 90 | realDir := t.TempDir() |
| 91 | realFile := filepath.Join(realDir, "file.txt") |
| 92 | if err := os.WriteFile(realFile, []byte("hello"), 0o644); err != nil { |
| 93 | t.Fatalf("write file: %v", err) |
| 94 | } |
| 95 | |
| 96 | linkDir := t.TempDir() |
| 97 | link1 := filepath.Join(linkDir, "link1") |
| 98 | if err := os.Symlink(realDir, link1); err != nil { |
| 99 | t.Skipf("symlink not supported: %v", err) |
| 100 | } |
| 101 | link2 := filepath.Join(linkDir, "link2") |
| 102 | if err := os.Symlink(link1, link2); err != nil { |
| 103 | t.Skipf("nested symlink not supported: %v", err) |
| 104 | } |
| 105 | |
| 106 | got, err := CanonicalPath(filepath.Join(link2, "file.txt")) |
| 107 | if err != nil { |
| 108 | t.Fatalf("CanonicalPath: %v", err) |
| 109 | } |
| 110 | want, _ := filepath.EvalSymlinks(realFile) |
| 111 | if got != want { |
| 112 | t.Errorf("CanonicalPath through nested symlinks = %q, want %q", got, want) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | func TestWithinBase_AdditionalCases(t *testing.T) { |
| 117 | cases := []struct { |
nothing calls this directly
no test coverage detected