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