forked from TrueCloudLab/rclone
fstest: add fs.ErrorCantShareDirectories for backends which can only share files
This commit is contained in:
parent
8fdce31700
commit
5a44bafa4e
2 changed files with 23 additions and 18 deletions
1
fs/fs.go
1
fs/fs.go
|
@ -68,6 +68,7 @@ var (
|
||||||
ErrorDirectoryNotEmpty = errors.New("directory not empty")
|
ErrorDirectoryNotEmpty = errors.New("directory not empty")
|
||||||
ErrorImmutableModified = errors.New("immutable file modified")
|
ErrorImmutableModified = errors.New("immutable file modified")
|
||||||
ErrorPermissionDenied = errors.New("permission denied")
|
ErrorPermissionDenied = errors.New("permission denied")
|
||||||
|
ErrorCantShareDirectories = errors.New("this backend can't share directories with link")
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegInfo provides information about a filesystem
|
// RegInfo provides information about a filesystem
|
||||||
|
|
|
@ -1410,27 +1410,31 @@ func Run(t *testing.T, opt *Opt) {
|
||||||
// sharing directory for the first time
|
// sharing directory for the first time
|
||||||
path := path.Dir(file2.Path)
|
path := path.Dir(file2.Path)
|
||||||
link3, err := doPublicLink(context.Background(), path)
|
link3, err := doPublicLink(context.Background(), path)
|
||||||
require.NoError(t, err)
|
if err != nil && errors.Cause(err) == fs.ErrorCantShareDirectories {
|
||||||
require.NotEqual(t, "", link3, "Link should not be empty")
|
t.Log("skipping directory tests as not supported on this backend")
|
||||||
|
} else {
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotEqual(t, "", link3, "Link should not be empty")
|
||||||
|
|
||||||
// sharing directory for the second time
|
// sharing directory for the second time
|
||||||
link3, err = doPublicLink(context.Background(), path)
|
link3, err = doPublicLink(context.Background(), path)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotEqual(t, "", link3, "Link should not be empty")
|
require.NotEqual(t, "", link3, "Link should not be empty")
|
||||||
|
|
||||||
// sharing the "root" directory in a subremote
|
// sharing the "root" directory in a subremote
|
||||||
subRemote, _, removeSubRemote, err := fstest.RandomRemote(remoteName, false)
|
subRemote, _, removeSubRemote, err := fstest.RandomRemote(remoteName, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer removeSubRemote()
|
defer removeSubRemote()
|
||||||
// ensure sub remote isn't empty
|
// ensure sub remote isn't empty
|
||||||
buf := bytes.NewBufferString("somecontent")
|
buf := bytes.NewBufferString("somecontent")
|
||||||
obji := object.NewStaticObjectInfo("somefile", time.Now(), int64(buf.Len()), true, nil, nil)
|
obji := object.NewStaticObjectInfo("somefile", time.Now(), int64(buf.Len()), true, nil, nil)
|
||||||
_, err = subRemote.Put(context.Background(), buf, obji)
|
_, err = subRemote.Put(context.Background(), buf, obji)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
link4, err := subRemote.Features().PublicLink(context.Background(), "")
|
link4, err := subRemote.Features().PublicLink(context.Background(), "")
|
||||||
require.NoError(t, err, "Sharing root in a sub-remote should work")
|
require.NoError(t, err, "Sharing root in a sub-remote should work")
|
||||||
require.NotEqual(t, "", link4, "Link should not be empty")
|
require.NotEqual(t, "", link4, "Link should not be empty")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// TestSetTier tests SetTier and GetTier functionality
|
// TestSetTier tests SetTier and GetTier functionality
|
||||||
|
|
Loading…
Add table
Reference in a new issue