From 5a44bafa4e46ad0530ec80f8d3fc4119f7bee73b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 24 Jul 2019 16:57:56 +0100 Subject: [PATCH] fstest: add fs.ErrorCantShareDirectories for backends which can only share files --- fs/fs.go | 1 + fstest/fstests/fstests.go | 40 +++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/fs/fs.go b/fs/fs.go index 4166c349c..81bd80001 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -68,6 +68,7 @@ var ( ErrorDirectoryNotEmpty = errors.New("directory not empty") ErrorImmutableModified = errors.New("immutable file modified") ErrorPermissionDenied = errors.New("permission denied") + ErrorCantShareDirectories = errors.New("this backend can't share directories with link") ) // RegInfo provides information about a filesystem diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go index c144b7319..d127f2eb6 100644 --- a/fstest/fstests/fstests.go +++ b/fstest/fstests/fstests.go @@ -1410,27 +1410,31 @@ func Run(t *testing.T, opt *Opt) { // sharing directory for the first time path := path.Dir(file2.Path) link3, err := doPublicLink(context.Background(), path) - require.NoError(t, err) - require.NotEqual(t, "", link3, "Link should not be empty") + if err != nil && errors.Cause(err) == fs.ErrorCantShareDirectories { + 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 - link3, err = doPublicLink(context.Background(), path) - require.NoError(t, err) - require.NotEqual(t, "", link3, "Link should not be empty") + // sharing directory for the second time + link3, err = doPublicLink(context.Background(), path) + require.NoError(t, err) + require.NotEqual(t, "", link3, "Link should not be empty") - // sharing the "root" directory in a subremote - subRemote, _, removeSubRemote, err := fstest.RandomRemote(remoteName, false) - require.NoError(t, err) - defer removeSubRemote() - // ensure sub remote isn't empty - buf := bytes.NewBufferString("somecontent") - obji := object.NewStaticObjectInfo("somefile", time.Now(), int64(buf.Len()), true, nil, nil) - _, err = subRemote.Put(context.Background(), buf, obji) - require.NoError(t, err) + // sharing the "root" directory in a subremote + subRemote, _, removeSubRemote, err := fstest.RandomRemote(remoteName, false) + require.NoError(t, err) + defer removeSubRemote() + // ensure sub remote isn't empty + buf := bytes.NewBufferString("somecontent") + obji := object.NewStaticObjectInfo("somefile", time.Now(), int64(buf.Len()), true, nil, nil) + _, err = subRemote.Put(context.Background(), buf, obji) + require.NoError(t, err) - link4, err := subRemote.Features().PublicLink(context.Background(), "") - require.NoError(t, err, "Sharing root in a sub-remote should work") - require.NotEqual(t, "", link4, "Link should not be empty") + link4, err := subRemote.Features().PublicLink(context.Background(), "") + require.NoError(t, err, "Sharing root in a sub-remote should work") + require.NotEqual(t, "", link4, "Link should not be empty") + } }) // TestSetTier tests SetTier and GetTier functionality