From 4b4ee7279643ef2421ac34ef959490a0b7001b1b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 18 Jun 2020 17:50:12 +0100 Subject: [PATCH] fstest: fix PublicLink tests to send non zero expiry and work with s3 --- fstest/fstests/fstests.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go index be5bff060..5e2de4eca 100644 --- a/fstest/fstests/fstests.go +++ b/fstest/fstests/fstests.go @@ -1466,38 +1466,40 @@ func Run(t *testing.T, opt *Opt) { t.Skip("FS has no PublicLinker interface") } + expiry := fs.Duration(60 * time.Second) + // if object not found - link, err := doPublicLink(ctx, file1.Path+"_does_not_exist", fs.Duration(0), false) + link, err := doPublicLink(ctx, file1.Path+"_does_not_exist", expiry, false) require.Error(t, err, "Expected to get error when file doesn't exist") require.Equal(t, "", link, "Expected link to be empty on error") // sharing file for the first time - link1, err := doPublicLink(ctx, file1.Path, fs.Duration(0), false) + link1, err := doPublicLink(ctx, file1.Path, expiry, false) require.NoError(t, err) require.NotEqual(t, "", link1, "Link should not be empty") - link2, err := doPublicLink(ctx, file2.Path, fs.Duration(0), false) + link2, err := doPublicLink(ctx, file2.Path, expiry, false) require.NoError(t, err) require.NotEqual(t, "", link2, "Link should not be empty") require.NotEqual(t, link1, link2, "Links to different files should differ") // sharing file for the 2nd time - link1, err = doPublicLink(ctx, file1.Path, fs.Duration(0), false) + link1, err = doPublicLink(ctx, file1.Path, expiry, false) require.NoError(t, err) require.NotEqual(t, "", link1, "Link should not be empty") // sharing directory for the first time path := path.Dir(file2.Path) - link3, err := doPublicLink(ctx, path, fs.Duration(0), false) - if err != nil && errors.Cause(err) == fs.ErrorCantShareDirectories { + link3, err := doPublicLink(ctx, path, expiry, false) + if err != nil && (errors.Cause(err) == fs.ErrorCantShareDirectories || errors.Cause(err) == fs.ErrorObjectNotFound) { 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(ctx, path, fs.Duration(0), false) + link3, err = doPublicLink(ctx, path, expiry, false) require.NoError(t, err) require.NotEqual(t, "", link3, "Link should not be empty") @@ -1511,7 +1513,7 @@ func Run(t *testing.T, opt *Opt) { _, err = subRemote.Put(ctx, buf, obji) require.NoError(t, err) - link4, err := subRemote.Features().PublicLink(ctx, "", fs.Duration(0), false) + link4, err := subRemote.Features().PublicLink(ctx, "", expiry, false) require.NoError(t, err, "Sharing root in a sub-remote should work") require.NotEqual(t, "", link4, "Link should not be empty") }