remove IsAbs validation on local volume
use MakeAbsolutePath to convert path in Windows fix test error: allow relative path for local volume fix comments fix comments and add windows unit tests
This commit is contained in:
@@ -976,3 +976,49 @@ func TestGetWindowsPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMakeAbsolutePath(t *testing.T) {
|
||||
tests := []struct {
|
||||
goos string
|
||||
path string
|
||||
expectedPath string
|
||||
name string
|
||||
}{
|
||||
{
|
||||
goos: "linux",
|
||||
path: "non-absolute/path",
|
||||
expectedPath: "/non-absolute/path",
|
||||
name: "basic linux",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "some\\path",
|
||||
expectedPath: "c:\\some\\path",
|
||||
name: "basic windows",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "/some/path",
|
||||
expectedPath: "c:/some/path",
|
||||
name: "linux path on windows",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "\\some\\path",
|
||||
expectedPath: "c:\\some\\path",
|
||||
name: "windows path no drive",
|
||||
},
|
||||
{
|
||||
goos: "windows",
|
||||
path: "\\:\\some\\path",
|
||||
expectedPath: "\\:\\some\\path",
|
||||
name: "windows path with colon",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
path := MakeAbsolutePath(test.goos, test.path)
|
||||
if path != test.expectedPath {
|
||||
t.Errorf("[%s] Expected %s saw %s", test.name, test.expectedPath, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user