(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestCanonicalPath_RelativePath(t *testing.T) { |
| 68 | dir := t.TempDir() |
| 69 | file := filepath.Join(dir, "test.txt") |
| 70 | if err := os.WriteFile(file, []byte("x"), 0o644); err != nil { |
| 71 | t.Fatalf("create file: %v", err) |
| 72 | } |
| 73 | |
| 74 | oldWd, err := os.Getwd() |
| 75 | if err != nil { |
| 76 | t.Fatalf("Getwd: %v", err) |
| 77 | } |
| 78 | t.Cleanup(func() { _ = os.Chdir(oldWd) }) |
| 79 | if err := os.Chdir(dir); err != nil { |
| 80 | t.Fatalf("Chdir: %v", err) |
| 81 | } |
| 82 | |
| 83 | got, err := CanonicalPath("test.txt") |
| 84 | if err != nil { |
| 85 | t.Fatalf("CanonicalPath: %v", err) |
| 86 | } |
| 87 | if !filepath.IsAbs(got) { |
| 88 | t.Errorf("result should be absolute, got %q", got) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func TestCanonicalPath_NestedSymlink(t *testing.T) { |
| 93 | realDir := t.TempDir() |
nothing calls this directly
no test coverage detected