Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fstests: Use a different container after the Rmdir

Nick Craig-Wood7ec24ad67a01
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index af48766fd..dafae4564 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -54,6 +54,22 @@ var (
// ExtraConfigItem describes a config item added on the fly while testing
type ExtraConfigItem struct{ Name, Key, Value string }
+// Make the Fs we are testing with, initialising the global variables
+// subRemoteName - name of the remote after the TestRemote:
+// subRemoteLeaf - a subdirectory to use under that
+// remote - the result of fs.NewFs(TestRemote:subRemoteName)
+func newFs(t *testing.T) {
+ var err error
+ subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(RemoteName)
+ require.NoError(t, err)
+ remote, err = fs.NewFs(subRemoteName)
+ if err == fs.ErrorNotFoundInConfigFile {
+ t.Logf("Didn't find %q in config file - skipping tests", RemoteName)
+ return
+ }
+ require.NoError(t, err, fmt.Sprintf("unexpected error: %v", err))
+}
+
// TestInit tests basic intitialisation
func TestInit(t *testing.T) {
var err error
@@ -79,15 +95,10 @@ func TestInit(t *testing.T) {
require.NoError(t, err)
isLocalRemote = true
}
- subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(RemoteName)
- require.NoError(t, err)
- remote, err = fs.NewFs(subRemoteName)
- if err == fs.ErrorNotFoundInConfigFile {
- t.Logf("Didn't find %q in config file - skipping tests", RemoteName)
- return
- }
- require.NoError(t, err, fmt.Sprintf("unexpected error: %v", err))
+ newFs(t)
+
+ skipIfNotOk(t)
fstest.TestMkdir(t, remote)
}
@@ -158,6 +169,12 @@ func TestFsRmdirNotFound(t *testing.T) {
// TestFsMkdir tests tests making a directory
func TestFsMkdir(t *testing.T) {
skipIfNotOk(t)
+
+ // Use a new directory here. This is for the container based
+ // remotes which take time to create and destroy a container
+ // (eg azure blob)
+ newFs(t)
+
fstest.TestMkdir(t, remote)
fstest.TestMkdir(t, remote)
}