From 7ec24ad67a01501788f903e39da12d46c3fde8cd Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 27 Jul 2017 08:27:24 +0100 Subject: [PATCH] fstests: Use a different container after the Rmdir Use a new directory here. This is for the container based remotes which take time to create and destroy a container (eg azure blob) --- fstest/fstests/fstests.go | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) 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) }