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", "/bar/foo/baz", true},
|
||||||
{"/bar/foo/baz", "/bar/foo", false},
|
{"/bar/foo/baz", "/bar/foo", false},
|
||||||
{"/bar/foo", "/bar/foo/.wierd..dirname/", true},
|
{"/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" {
|
if runtime.GOOS == "windows" {
|
||||||
cases = append(
|
cases = append(
|
||||||
cases,
|
cases,
|
||||||
inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", true},
|
inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", true},
|
||||||
)
|
inPathTestCase{"c:\\bar\\foo", "C:\\bar\\foo", false},
|
||||||
} else {
|
inPathTestCase{"c:\\bar\\..\\bar\\foo", "C:\\bar\\foo\\baz", true},
|
||||||
cases = append(
|
|
||||||
cases,
|
|
||||||
inPathTestCase{"C:/Bar/foo", "c:/bar/foo/baz", false},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
ip := inPath(tc.Src, tc.Prj)
|
ip := inPath(tc.Src, tc.Prj)
|
||||||
if tc.InPath != ip {
|
if tc.InPath != ip {
|
||||||
if tc.InPath {
|
if ip {
|
||||||
t.Errorf("Unexpected %s determined as inside %s", tc.Prj, tc.Src)
|
|
||||||
} else {
|
|
||||||
t.Errorf("Unexpected %s determined as not inside %s", tc.Prj, tc.Src)
|
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