26 lines
630 B
Go
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")
|
||
|
|
}
|
||
|
|
}
|