mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 00:43:49 +01:00
Add tests for --delete-before, --delete-during and --delete-after
This commit is contained in:
parent
12b51c5eb8
commit
74a71f7824
@ -565,6 +565,63 @@ func TestSyncAfterRemovingAFileAndAddingAFile(t *testing.T) {
|
||||
fstest.CheckItems(t, r.fremote, file1, file3)
|
||||
}
|
||||
|
||||
// Sync after removing a file and adding a file with IO Errors
|
||||
func TestSyncAfterRemovingAFileAndAddingAFileWithErrors(t *testing.T) {
|
||||
r := NewRun(t)
|
||||
defer r.Finalise()
|
||||
file1 := r.WriteFile("potato2", "------------------------------------------------------------", t1)
|
||||
file2 := r.WriteObject("potato", "SMALLER BUT SAME DATE", t2)
|
||||
file3 := r.WriteBoth("empty space", "", t2)
|
||||
fstest.CheckItems(t, r.fremote, file2, file3)
|
||||
fstest.CheckItems(t, r.flocal, file1, file3)
|
||||
|
||||
fs.Stats.ResetCounters()
|
||||
fs.Stats.Error()
|
||||
err := fs.Sync(r.fremote, r.flocal)
|
||||
if err != nil {
|
||||
t.Fatalf("Sync failed: %v", err)
|
||||
}
|
||||
fstest.CheckItems(t, r.flocal, file1, file3)
|
||||
fstest.CheckItems(t, r.fremote, file1, file2, file3)
|
||||
}
|
||||
|
||||
// Sync test delete during
|
||||
func TestSyncDeleteDuring(t *testing.T) {
|
||||
// This is the default so we've checked this already
|
||||
// check it is the default
|
||||
if !(!fs.Config.DeleteBefore && fs.Config.DeleteDuring && !fs.Config.DeleteAfter) {
|
||||
t.Fatalf("Didn't default to --delete-during")
|
||||
}
|
||||
}
|
||||
|
||||
// Sync test delete before
|
||||
func TestSyncDeleteBefore(t *testing.T) {
|
||||
fs.Config.DeleteBefore = true
|
||||
fs.Config.DeleteDuring = false
|
||||
fs.Config.DeleteAfter = false
|
||||
defer func() {
|
||||
fs.Config.DeleteBefore = false
|
||||
fs.Config.DeleteDuring = true
|
||||
fs.Config.DeleteAfter = false
|
||||
}()
|
||||
|
||||
TestSyncAfterRemovingAFileAndAddingAFile(t)
|
||||
}
|
||||
|
||||
// Sync test delete after
|
||||
func TestSyncDeleteAfter(t *testing.T) {
|
||||
fs.Config.DeleteBefore = false
|
||||
fs.Config.DeleteDuring = false
|
||||
fs.Config.DeleteAfter = true
|
||||
defer func() {
|
||||
fs.Config.DeleteBefore = false
|
||||
fs.Config.DeleteDuring = true
|
||||
fs.Config.DeleteAfter = false
|
||||
}()
|
||||
|
||||
TestSyncAfterRemovingAFileAndAddingAFile(t)
|
||||
}
|
||||
|
||||
// Test with exclude
|
||||
func TestSyncWithExclude(t *testing.T) {
|
||||
r := NewRun(t)
|
||||
|
Loading…
Reference in New Issue
Block a user