mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Run windows valid path test cases only if runtime.GOOS == "windows"
This commit is contained in:
parent
6296a316b8
commit
895387ad4b
1 changed files with 5 additions and 10 deletions
|
@ -52,28 +52,23 @@ func TestInPath(t *testing.T) {
|
|||
{"/bar/foo", "/bar/foo/baz", true},
|
||||
{"/bar/foo/baz", "/bar/foo", false},
|
||||
{"/bar/foo", "/bar/foo/.wierd..dirname/", true},
|
||||
{"c:\\bar\\foo", "C:\\bar\\foo", false},
|
||||
{"c:\\bar\\..\\bar\\foo", "C:\\bar\\foo\\baz", true},
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
cases = append(
|
||||
cases,
|
||||
inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", true},
|
||||
)
|
||||
} else {
|
||||
cases = append(
|
||||
cases,
|
||||
inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", false},
|
||||
inPathTestCase{"c:\\bar\\foo", "C:\\bar\\foo", false},
|
||||
inPathTestCase{"c:\\bar\\..\\bar\\foo", "C:\\bar\\foo\\baz", true},
|
||||
)
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
ip := inPath(tc.Src, tc.Prj)
|
||||
if tc.InPath != ip {
|
||||
if tc.InPath {
|
||||
t.Errorf("Unexpected %s determined as inside %s", tc.Prj, tc.Src)
|
||||
} else {
|
||||
if ip {
|
||||
t.Errorf("Unexpected %s determined as not inside %s", tc.Prj, tc.Src)
|
||||
} else {
|
||||
t.Errorf("Unexpected %s determined as inside %s", tc.Prj, tc.Src)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue