mirror of
https://github.com/rclone/rclone.git
synced 2024-12-22 23:22:08 +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:
parent
56ce784301
commit
9fbc40c5b9
@ -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).
|
||||
`
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user