1
mirror of https://github.com/rclone/rclone synced 2024-11-01 21:49:35 +01:00

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:06:51 +01:00
parent 56ce784301
commit 9fbc40c5b9
2 changed files with 26 additions and 2 deletions

View File

@ -19,4 +19,8 @@ There are several related list commands
Note that ` + "`ls`,`lsl`,`lsd`" + ` all recurse by default - use "--max-depth 1" to stop the recursion.
The other list commands ` + "`lsf`,`lsjson`" + ` do not recurse by default - use "-R" to make them recurse.
Listing a non existent directory will produce an error except for
remotes which can't have empty directories (eg s3, swift, gcs, etc -
the bucket based remotes).
`

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)