fstest: Fix TestPurge causing errors with subsequent tests on azure

Before this change TestPurge would remove a container and subsequent
tests would fail because the container was still being deleted so
couldn't be created.

This was fixed by introducing an fstest.NewRunIndividual() test runner
for TestPurge which causes the test to be run on a new container.
This commit is contained in:
Nick Craig-Wood 2018-11-14 17:14:02 +00:00
parent f7ce2e8d95
commit f92beb4e14
2 changed files with 22 additions and 5 deletions

View File

@ -404,7 +404,7 @@ func TestRcat(t *testing.T) {
}
func TestPurge(t *testing.T) {
r := fstest.NewRun(t)
r := fstest.NewRunIndividual(t) // make new container (azureblob has delayed mkdir after rmdir)
defer r.Finalise()
r.Mkdir(r.Fremote)

View File

@ -121,16 +121,17 @@ func retry(t *testing.T, what string, f func() error) {
t.Logf("%s failed: %v", what, err)
}
// NewRun initialise the remote and local for testing and returns a
// run object. Call this from the tests.
// newRunIndividual initialise the remote and local for testing and
// returns a run object. Pass in true to make individual tests or
// false to use the global one.
//
// r.Flocal is an empty local Fs
// r.Fremote is an empty remote Fs
//
// Finalise() will tidy them away when done.
func NewRun(t *testing.T) *Run {
func newRunIndividual(t *testing.T, individual bool) *Run {
var r *Run
if *Individual {
if individual {
r = newRun()
} else {
// If not individual, use the global one with the clean method overridden
@ -176,6 +177,22 @@ func NewRun(t *testing.T) *Run {
return r
}
// NewRun initialise the remote and local for testing and returns a
// run object. Call this from the tests.
//
// r.Flocal is an empty local Fs
// r.Fremote is an empty remote Fs
//
// Finalise() will tidy them away when done.
func NewRun(t *testing.T) *Run {
return newRunIndividual(t, *Individual)
}
// NewRunIndividual as per NewRun but makes an individual remote for this test
func NewRunIndividual(t *testing.T) *Run {
return newRunIndividual(t, true)
}
// RenameFile renames a file in local
func (r *Run) RenameFile(item Item, newpath string) Item {
oldFilepath := path.Join(r.LocalName, item.Path)