mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
lib/osutil: Use filepath.Join in tests (#6740)
This commit is contained in:
parent
091cb5e611
commit
fdf5a5c0d7
@ -26,25 +26,25 @@ func TestIsDeleted(t *testing.T) {
|
||||
cases := []tc{
|
||||
{"del", true},
|
||||
{"del.file", false},
|
||||
{"del/del", true},
|
||||
{filepath.Join("del", "del"), true},
|
||||
{"file", false},
|
||||
{"linkToFile", false},
|
||||
{"linkToDel", false},
|
||||
{"linkToDir", false},
|
||||
{"linkToDir/file", true},
|
||||
{"file/behindFile", true},
|
||||
{filepath.Join("linkToDir", "file"), true},
|
||||
{filepath.Join("file", "behindFile"), true},
|
||||
{"dir", false},
|
||||
{"dir.file", false},
|
||||
{"dir/file", false},
|
||||
{"dir/del", true},
|
||||
{"dir/del/del", true},
|
||||
{"del/del/del", true},
|
||||
{filepath.Join("dir", "file"), false},
|
||||
{filepath.Join("dir", "del"), true},
|
||||
{filepath.Join("dir", "del", "del"), true},
|
||||
{filepath.Join("del", "del", "del"), true},
|
||||
}
|
||||
|
||||
testFs := fs.NewFilesystem(fs.FilesystemTypeBasic, "testdata")
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -55,9 +55,9 @@ func TestIsDeleted(t *testing.T) {
|
||||
// Can't create unreadable dir on windows
|
||||
testFs.MkdirAll("inacc", 0777)
|
||||
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
|
||||
cases = append(cases, tc{"inacc", false}, tc{"inacc/file", false})
|
||||
cases = append(cases, tc{"inacc", false}, tc{filepath.Join("inacc", "file"), false})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user