acd: extend move test to check conflict cases for two step rename+move
This commit is contained in:
parent
ca017980a3
commit
77f38cb6f1
1 changed files with 34 additions and 12 deletions
|
@ -405,30 +405,52 @@ func TestFsMove(t *testing.T) {
|
||||||
t.Skip("FS has no Mover interface")
|
t.Skip("FS has no Mover interface")
|
||||||
}
|
}
|
||||||
|
|
||||||
var file1Move = file1
|
// state of files now:
|
||||||
file1Move.Path += "-move"
|
// 1: file name.txt
|
||||||
|
// 2: hello sausage?/../z.txt
|
||||||
|
|
||||||
// do the move
|
var file1Move = file1
|
||||||
src := findObject(t, file1.Path)
|
var file2Move = file2
|
||||||
dst, err := remote.(fs.Mover).Move(src, file1Move.Path)
|
|
||||||
|
// check happy path, i.e. no naming conflicts when rename and move are two
|
||||||
|
// separate operations
|
||||||
|
file2Move.Path = "other.txt"
|
||||||
|
src := findObject(t, file2.Path)
|
||||||
|
dst, err := remote.(fs.Mover).Move(src, file2Move.Path)
|
||||||
if err == fs.ErrorCantMove {
|
if err == fs.ErrorCantMove {
|
||||||
t.Skip("FS can't move")
|
t.Skip("FS can't move")
|
||||||
}
|
}
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// check file exists in new listing
|
// check file exists in new listing
|
||||||
fstest.CheckListing(t, remote, []fstest.Item{file2, file1Move})
|
fstest.CheckListing(t, remote, []fstest.Item{file1, file2Move})
|
||||||
|
|
||||||
// Check dst lightly - list above has checked ModTime/Hashes
|
// Check dst lightly - list above has checked ModTime/Hashes
|
||||||
assert.Equal(t, file1Move.Path, dst.Remote())
|
assert.Equal(t, file2Move.Path, dst.Remote())
|
||||||
|
// 1: file name.txt
|
||||||
|
// 2: other.txt
|
||||||
|
|
||||||
// move it back
|
// Check conflict on "rename, then move"
|
||||||
|
file1Move.Path = "moveTest/other.txt"
|
||||||
|
src = findObject(t, file1.Path)
|
||||||
|
_, err = remote.(fs.Mover).Move(src, file1Move.Path)
|
||||||
|
require.NoError(t, err)
|
||||||
|
fstest.CheckListing(t, remote, []fstest.Item{file1Move, file2Move})
|
||||||
|
// 1: moveTest/other.txt
|
||||||
|
// 2: other.txt
|
||||||
|
|
||||||
|
// Check conflict on "move, then rename"
|
||||||
src = findObject(t, file1Move.Path)
|
src = findObject(t, file1Move.Path)
|
||||||
_, err = remote.(fs.Mover).Move(src, file1.Path)
|
_, err = remote.(fs.Mover).Move(src, file1.Path)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
fstest.CheckListing(t, remote, []fstest.Item{file1, file2Move})
|
||||||
|
// 1: file name.txt
|
||||||
|
// 2: other.txt
|
||||||
|
|
||||||
// check file exists in new listing
|
src = findObject(t, file2Move.Path)
|
||||||
fstest.CheckListing(t, remote, []fstest.Item{file2, file1})
|
_, err = remote.(fs.Mover).Move(src, file2.Path)
|
||||||
|
require.NoError(t, err)
|
||||||
|
fstest.CheckListing(t, remote, []fstest.Item{file1, file2})
|
||||||
|
// 1: file name.txt
|
||||||
|
// 2: hello sausage?/../z.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move src to this remote using server side move operations.
|
// Move src to this remote using server side move operations.
|
||||||
|
|
Loading…
Add table
Reference in a new issue