mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 07:29:35 +01:00
fstest: fix PublicLink tests to send non zero expiry and work with s3
This commit is contained in:
parent
40611fc4fc
commit
4b4ee72796
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user