1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-15 15:53:41 +00:00

Implement moveto and copyto commands for choosing a destination name on copy/move

Fixes #227
Fixes #476
This commit is contained in:
Nick Craig-Wood
2016-10-23 17:34:17 +01:00
parent 2058652fa4
commit c265f451f2
10 changed files with 332 additions and 26 deletions

View File

@@ -697,3 +697,48 @@ func TestRmdirs(t *testing.T) {
)
}
func TestMoveFile(t *testing.T) {
r := NewRun(t)
defer r.Finalise()
file1 := r.WriteFile("file1", "file1 contents", t1)
fstest.CheckItems(t, r.flocal, file1)
file2 := file1
file2.Path = "sub/file2"
err := fs.MoveFile(r.fremote, r.flocal, file2.Path, file1.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.flocal)
fstest.CheckItems(t, r.fremote, file2)
r.WriteFile("file1", "file1 contents", t1)
fstest.CheckItems(t, r.flocal, file1)
err = fs.MoveFile(r.fremote, r.flocal, file2.Path, file1.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.flocal)
fstest.CheckItems(t, r.fremote, file2)
}
func TestCopyFile(t *testing.T) {
r := NewRun(t)
defer r.Finalise()
file1 := r.WriteFile("file1", "file1 contents", t1)
fstest.CheckItems(t, r.flocal, file1)
file2 := file1
file2.Path = "sub/file2"
err := fs.CopyFile(r.fremote, r.flocal, file2.Path, file1.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.flocal, file1)
fstest.CheckItems(t, r.fremote, file2)
err = fs.CopyFile(r.fremote, r.flocal, file2.Path, file1.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.flocal, file1)
fstest.CheckItems(t, r.fremote, file2)
}