Files
code-utils/platform/path_test.go
2026-08-11 19:07:05 +08:00

26 lines
630 B
Go

package platform
import "testing"
func TestResolveWSLPaths(t *testing.T) {
cases := []struct{ input, distro, linux string }{{`\\wsl.localhost\Ubuntu-24.04\home\lee\app`, "Ubuntu-24.04", "/home/lee/app"}, {`\\wsl$\Debian\opt\site`, "Debian", "/opt/site"}}
for _, c := range cases {
d, e := ResolvePath(c.input)
if e != nil {
t.Fatal(e)
}
if !d.WSL || d.Distro != c.distro || d.LinuxPath != c.linux {
t.Fatalf("%q => %#v", c.input, d)
}
}
}
func TestResolveWindowsPath(t *testing.T) {
d, e := ResolvePath(`D:\code\app`)
if e != nil {
t.Fatal(e)
}
if d.WSL {
t.Fatal("windows path detected as WSL")
}
}