lib/osutil: Use filepath.Join in tests (#6740)

This commit is contained in:
Simon Frei 2020-06-14 20:09:37 +02:00 committed by GitHub
parent 091cb5e611
commit fdf5a5c0d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,25 +26,25 @@ func TestIsDeleted(t *testing.T) {
cases := []tc{ cases := []tc{
{"del", true}, {"del", true},
{"del.file", false}, {"del.file", false},
{"del/del", true}, {filepath.Join("del", "del"), true},
{"file", false}, {"file", false},
{"linkToFile", false}, {"linkToFile", false},
{"linkToDel", false}, {"linkToDel", false},
{"linkToDir", false}, {"linkToDir", false},
{"linkToDir/file", true}, {filepath.Join("linkToDir", "file"), true},
{"file/behindFile", true}, {filepath.Join("file", "behindFile"), true},
{"dir", false}, {"dir", false},
{"dir.file", false}, {"dir.file", false},
{"dir/file", false}, {filepath.Join("dir", "file"), false},
{"dir/del", true}, {filepath.Join("dir", "del"), true},
{"dir/del/del", true}, {filepath.Join("dir", "del", "del"), true},
{"del/del/del", true}, {filepath.Join("del", "del", "del"), true},
} }
testFs := fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata") testFs := fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata")
testFs.MkdirAll("dir", 0777) testFs.MkdirAll("dir", 0777)
for _, f := range []string{"file", "del.file", "dir.file", "dir/file"} { for _, f := range []string{"file", "del.file", "dir.file", filepath.Join("dir", "file")} {
fd, err := testFs.Create(f) fd, err := testFs.Create(f)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -55,9 +55,9 @@ func TestIsDeleted(t *testing.T) {
// Can't create unreadable dir on windows // Can't create unreadable dir on windows
testFs.MkdirAll("inacc", 0777) testFs.MkdirAll("inacc", 0777)
if err := testFs.Chmod("inacc", 0000); err == nil { if err := testFs.Chmod("inacc", 0000); err == nil {
if _, err := testFs.Lstat("inacc/file"); fs.IsPermission(err) { if _, err := testFs.Lstat(filepath.Join("inacc", "file")); fs.IsPermission(err) {
// May fail e.g. if tests are run as root -> just skip // May fail e.g. if tests are run as root -> just skip
cases = append(cases, tc{"inacc", false}, tc{"inacc/file", false}) cases = append(cases, tc{"inacc", false}, tc{filepath.Join("inacc", "file"), false})
} }
} }
} }