| 1 | package env |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/sylvinus/agent-vm/internal/paths" |
| 8 | ) |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | func TestProjectRelWindows(t *testing.T) { |
| 14 | old := paths.Windows |
| 15 | paths.Windows = func() bool { return true } |
| 16 | t.Cleanup(func() { paths.Windows = old }) |
| 17 | t.Chdir(t.TempDir()) |
| 18 | os.MkdirAll("C:/p", 0o755) |
| 19 | os.Symlink("p", "C:/link") |
| 20 | for target, want := range map[string]string{"C:/p/.env": ".env", "C:/link/.env": ".env", "C:/link/sub/x": "sub/x"} { |
| 21 | if rel, ok := ProjectRel("C:/p", target); !ok || rel != want { |
| 22 | t.Errorf("ProjectRel(C:/p, %q) = %q, %v", target, rel, ok) |
| 23 | } |
| 24 | } |
| 25 | if _, ok := ProjectRel("C:/p", "C:/other/.env"); ok { |
| 26 | t.Error("C:/other is not in the project") |
| 27 | } |
| 28 | } |