forked from TrueCloudLab/rclone
fs: Make tests create a new bucket rather than purging the old one
This enables QingStor to pass the tests as it has a 2 minute lockout on deleting the old bucket then creating it again.
This commit is contained in:
parent
7d34caac83
commit
f682002b84
1 changed files with 16 additions and 17 deletions
|
@ -687,7 +687,11 @@ func TestSyncWithTrackRenames(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test a server side move if possible, or the backup path if not
|
||||
func testServerSideMove(t *testing.T, r *Run, fremoteMove fs.Fs, withFilter bool) {
|
||||
func testServerSideMove(t *testing.T, r *Run, withFilter bool) {
|
||||
fremoteMove, _, finaliseMove, err := fstest.RandomRemote(*fstest.RemoteName, *fstest.SubDir)
|
||||
require.NoError(t, err)
|
||||
defer finaliseMove()
|
||||
|
||||
file1 := r.WriteBoth("potato2", "------------------------------------------------------------", t1)
|
||||
file2 := r.WriteBoth("empty space", "", t2)
|
||||
file3u := r.WriteBoth("potato3", "------------------------------------------------------------ UPDATED", t2)
|
||||
|
@ -703,7 +707,7 @@ func testServerSideMove(t *testing.T, r *Run, fremoteMove fs.Fs, withFilter bool
|
|||
|
||||
// Do server side move
|
||||
fs.Stats.ResetCounters()
|
||||
err := fs.MoveDir(fremoteMove, r.fremote)
|
||||
err = fs.MoveDir(fremoteMove, r.fremote)
|
||||
require.NoError(t, err)
|
||||
|
||||
if withFilter {
|
||||
|
@ -713,20 +717,21 @@ func testServerSideMove(t *testing.T, r *Run, fremoteMove fs.Fs, withFilter bool
|
|||
}
|
||||
fstest.CheckItems(t, fremoteMove, file2, file1, file3u)
|
||||
|
||||
// Purge the original before moving
|
||||
require.NoError(t, fs.Purge(r.fremote))
|
||||
fstest.CheckItems(t, r.fremote)
|
||||
// Create a new empty remote for stuff to be moved into
|
||||
fremoteMove2, _, finaliseMove2, err := fstest.RandomRemote(*fstest.RemoteName, *fstest.SubDir)
|
||||
require.NoError(t, err)
|
||||
defer finaliseMove2()
|
||||
|
||||
// Move it back again, dst does not exist this time
|
||||
// Move it back to a new empty remote, dst does not exist this time
|
||||
fs.Stats.ResetCounters()
|
||||
err = fs.MoveDir(r.fremote, fremoteMove)
|
||||
err = fs.MoveDir(fremoteMove2, fremoteMove)
|
||||
require.NoError(t, err)
|
||||
|
||||
if withFilter {
|
||||
fstest.CheckItems(t, r.fremote, file1, file3u)
|
||||
fstest.CheckItems(t, fremoteMove2, file1, file3u)
|
||||
fstest.CheckItems(t, fremoteMove, file2)
|
||||
} else {
|
||||
fstest.CheckItems(t, r.fremote, file2, file1, file3u)
|
||||
fstest.CheckItems(t, fremoteMove2, file2, file1, file3u)
|
||||
fstest.CheckItems(t, fremoteMove)
|
||||
}
|
||||
}
|
||||
|
@ -735,10 +740,7 @@ func testServerSideMove(t *testing.T, r *Run, fremoteMove fs.Fs, withFilter bool
|
|||
func TestServerSideMove(t *testing.T) {
|
||||
r := NewRun(t)
|
||||
defer r.Finalise()
|
||||
fremoteMove, _, finaliseMove, err := fstest.RandomRemote(*fstest.RemoteName, *fstest.SubDir)
|
||||
require.NoError(t, err)
|
||||
defer finaliseMove()
|
||||
testServerSideMove(t, r, fremoteMove, false)
|
||||
testServerSideMove(t, r, false)
|
||||
}
|
||||
|
||||
// Test a server side move if possible, or the backup path if not
|
||||
|
@ -751,10 +753,7 @@ func TestServerSideMoveWithFilter(t *testing.T) {
|
|||
fs.Config.Filter.MinSize = -1
|
||||
}()
|
||||
|
||||
fremoteMove, _, finaliseMove, err := fstest.RandomRemote(*fstest.RemoteName, *fstest.SubDir)
|
||||
require.NoError(t, err)
|
||||
defer finaliseMove()
|
||||
testServerSideMove(t, r, fremoteMove, true)
|
||||
testServerSideMove(t, r, true)
|
||||
}
|
||||
|
||||
// Test a server side move with overlap
|
||||
|
|
Loading…
Reference in a new issue