|
|
@ -17,7 +17,6 @@ |
|
|
|
package cmd |
|
|
|
package cmd |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"net/url" |
|
|
|
|
|
|
|
"runtime" |
|
|
|
"runtime" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
@ -100,51 +99,51 @@ func TestHouseKeeping(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Test constructing the final path.
|
|
|
|
// Test getPath() - the path that needs to be passed to newPosix()
|
|
|
|
func TestGetPath(t *testing.T) { |
|
|
|
func TestGetPath(t *testing.T) { |
|
|
|
var testCases []struct { |
|
|
|
var testCases []struct { |
|
|
|
ep *url.URL |
|
|
|
epStr string |
|
|
|
path string |
|
|
|
path string |
|
|
|
} |
|
|
|
} |
|
|
|
if runtime.GOOS != "windows" { |
|
|
|
if runtime.GOOS == "windows" { |
|
|
|
testCases = []struct { |
|
|
|
testCases = []struct { |
|
|
|
ep *url.URL |
|
|
|
epStr string |
|
|
|
path string |
|
|
|
path string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
{ |
|
|
|
{"\\export", "\\export"}, |
|
|
|
ep: nil, |
|
|
|
{"D:\\export", "d:\\export"}, |
|
|
|
path: "", |
|
|
|
{"D:\\", "d:\\"}, |
|
|
|
}, |
|
|
|
{"D:", "d:"}, |
|
|
|
{ |
|
|
|
{"\\", "\\"}, |
|
|
|
ep: &url.URL{Path: "/test1"}, |
|
|
|
{"http://localhost/d:/export", "d:/export"}, |
|
|
|
path: "/test1", |
|
|
|
{"https://localhost/d:/export", "d:/export"}, |
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
testCases = []struct { |
|
|
|
testCases = []struct { |
|
|
|
ep *url.URL |
|
|
|
epStr string |
|
|
|
path string |
|
|
|
path string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
{ |
|
|
|
{"/export", "/export"}, |
|
|
|
ep: nil, |
|
|
|
{"http://localhost/export", "/export"}, |
|
|
|
path: "", |
|
|
|
{"https://localhost/export", "/export"}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ep: &url.URL{Opaque: "\\test1", Scheme: "C"}, |
|
|
|
|
|
|
|
path: "C:\\test1", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ep: &url.URL{Scheme: "http", Path: "/C:\\test1"}, |
|
|
|
|
|
|
|
path: "C:\\test1", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
testCasesCommon := []struct { |
|
|
|
// Validate all the test cases.
|
|
|
|
epStr string |
|
|
|
for i, testCase := range testCases { |
|
|
|
path string |
|
|
|
path := getPath(testCase.ep) |
|
|
|
}{ |
|
|
|
if path != testCase.path { |
|
|
|
{"export", "export"}, |
|
|
|
t.Fatalf("Test: %d Expected path %s, got %s", i+1, testCase.path, path) |
|
|
|
} |
|
|
|
|
|
|
|
testCases = append(testCases, testCasesCommon...) |
|
|
|
|
|
|
|
for i, test := range testCases { |
|
|
|
|
|
|
|
eps, err := parseStorageEndpoints([]string{test.epStr}) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
t.Errorf("Test %d: %s - %s", i+1, test.epStr, err) |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
path := getPath(eps[0]) |
|
|
|
|
|
|
|
if path != test.path { |
|
|
|
|
|
|
|
t.Errorf("Test %d: For endpoing %s, getPath() failed, got: %s, expected: %s,", i+1, test.epStr, path, test.path) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|