fstests: List missing dir must return ErrorDirNotFound for non bucket based remotes

List or ListR of an non existent directory must return
ErrorDirNotFound for non bucket based remotes.  For bucket based
remotes it may return ErrorDirNotFound or it may return no error and
no entries.
This commit is contained in:
Nick Craig-Wood
2018-04-20 23:22:46 +01:00
parent 56ce784301
commit 9fbc40c5b9
2 changed files with 26 additions and 2 deletions
+22 -2
View File
@@ -335,6 +335,27 @@ func Run(t *testing.T, opt *Opt) {
TestFsListDirEmpty(t)
})
// TestFsListDirNotFound tests listing the directories from an empty directory
TestFsListDirNotFound := func(t *testing.T) {
skipIfNotOk(t)
objs, dirs, err := walk.GetAll(remote, "does not exist", true, 1)
if !remote.Features().CanHaveEmptyDirectories {
if err != fs.ErrorDirNotFound {
assert.NoError(t, err)
assert.Equal(t, 0, len(objs)+len(dirs))
}
} else {
assert.Equal(t, fs.ErrorDirNotFound, err)
}
}
t.Run("TestFsListDirNotFound", TestFsListDirNotFound)
// TestFsListRDirNotFound tests listing the directories from an empty directory using ListR
t.Run("TestFsListRDirNotFound", func(t *testing.T) {
defer skipIfNotListR(t)()
TestFsListDirNotFound(t)
})
// TestFsNewObjectNotFound tests not finding a object
t.Run("TestFsNewObjectNotFound", func(t *testing.T) {
skipIfNotOk(t)
@@ -666,10 +687,9 @@ func Run(t *testing.T, opt *Opt) {
require.NoError(t, err)
// check remotes
// FIXME: Prints errors.
// remote should not exist here
_, err = remote.List("")
require.Equal(t, fs.ErrorDirNotFound, errors.Cause(err))
assert.Equal(t, fs.ErrorDirNotFound, errors.Cause(err))
//fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{}, remote.Precision())
file1Copy := file1
file1Copy.Path = path.Join(newName, file1.Path)