"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
sync/operations: don't use zero length files in tests
Laura38ebdf54beb1
diff --git a/fs/operations/listdirsorted_test.go b/fs/operations/listdirsorted_test.goindex 10b9d62ec..dd962cf8c 100644--- a/fs/operations/listdirsorted_test.go+++ b/fs/operations/listdirsorted_test.go@@ -28,7 +28,7 @@ func TestListDirSorted(t *testing.T) {r.WriteObject(context.Background(), "zend.txt", "hello", t1),r.WriteObject(context.Background(), "sub dir/hello world", "hello world", t1),r.WriteObject(context.Background(), "sub dir/hello world2", "hello world", t1),- r.WriteObject(context.Background(), "sub dir/ignore dir/.ignore", "", t1),+ r.WriteObject(context.Background(), "sub dir/ignore dir/.ignore", "-", t1),r.WriteObject(context.Background(), "sub dir/ignore dir/should be ignored", "to ignore", t1),r.WriteObject(context.Background(), "sub dir/sub sub dir/hello world3", "hello world", t1),}diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.goindex de28661a8..0e050ed20 100644--- a/fs/operations/operations_test.go+++ b/fs/operations/operations_test.go@@ -89,7 +89,7 @@ func TestLs(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1)- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)fstest.CheckItems(t, r.Fremote, file1, file2)@@ -97,7 +97,7 @@ func TestLs(t *testing.T) {err := operations.List(context.Background(), r.Fremote, &buf)require.NoError(t, err)res := buf.String()- assert.Contains(t, res, " 0 empty space\n")+ assert.Contains(t, res, " 1 empty space\n")assert.Contains(t, res, " 60 potato2\n")}@@ -105,7 +105,7 @@ func TestLsWithFilesFrom(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1)- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)fstest.CheckItems(t, r.Fremote, file1, file2)@@ -144,7 +144,7 @@ func TestLsLong(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1)- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)fstest.CheckItems(t, r.Fremote, file1, file2)@@ -170,7 +170,7 @@ func TestLsLong(t *testing.T) {}}- m1 := regexp.MustCompile(`(?m)^ 0 (\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{9}) empty space$`)+ m1 := regexp.MustCompile(`(?m)^ 1 (\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{9}) empty space$`)if ms := m1.FindStringSubmatch(res); ms == nil {t.Errorf("empty space missing: %q", res)} else {@@ -189,7 +189,7 @@ func TestHashSums(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1)- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)fstest.CheckItems(t, r.Fremote, file1, file2)@@ -199,7 +199,7 @@ func TestHashSums(t *testing.T) {err := operations.Md5sum(context.Background(), r.Fremote, &buf)require.NoError(t, err)res := buf.String()- if !strings.Contains(res, "d41d8cd98f00b204e9800998ecf8427e empty space\n") &&+ if !strings.Contains(res, "336d5ebc5436534e61d16e63ddfca327 empty space\n") &&!strings.Contains(res, " UNSUPPORTED empty space\n") &&!strings.Contains(res, " empty space\n") {t.Errorf("empty space missing: %q", res)@@ -216,7 +216,7 @@ func TestHashSums(t *testing.T) {err = operations.Sha1sum(context.Background(), r.Fremote, &buf)require.NoError(t, err)res = buf.String()- if !strings.Contains(res, "da39a3ee5e6b4b0d3255bfef95601890afd80709 empty space\n") &&+ if !strings.Contains(res, "3bc15c8aae3e4124dd409035f32ea2fd6835efc9 empty space\n") &&!strings.Contains(res, " UNSUPPORTED empty space\n") &&!strings.Contains(res, " empty space\n") {t.Errorf("empty space missing: %q", res)@@ -233,7 +233,7 @@ func TestHashSums(t *testing.T) {err = operations.DropboxHashSum(context.Background(), r.Fremote, &buf)require.NoError(t, err)res = buf.String()- if !strings.Contains(res, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 empty space\n") &&+ if !strings.Contains(res, "fc62b10ec59efa8041f5a6c924d7c91572c1bbda280d9e01312b660804df1d47 empty space\n") &&!strings.Contains(res, " UNSUPPORTED empty space\n") &&!strings.Contains(res, " empty space\n") {t.Errorf("empty space missing: %q", res)@@ -276,7 +276,7 @@ func TestCount(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1)- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)file3 := r.WriteBoth(context.Background(), "sub dir/potato3", "hello", t2)fstest.CheckItems(t, r.Fremote, file1, file2, file3)@@ -288,7 +288,7 @@ func TestCount(t *testing.T) {objects, size, err := operations.Count(context.Background(), r.Fremote)require.NoError(t, err)assert.Equal(t, int64(2), objects)- assert.Equal(t, int64(60), size)+ assert.Equal(t, int64(61), size)}func TestDelete(t *testing.T) {@@ -351,7 +351,7 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, fdst, fsrcfstest.CheckItems(t, r.Flocal, file1, file2)check(2, 1, 1, false)- file3 := r.WriteObject(context.Background(), "empty space", "", t2)+ file3 := r.WriteObject(context.Background(), "empty space", "-", t2)fstest.CheckItems(t, r.Fremote, file1, file3)check(3, 2, 1, false)@@ -364,7 +364,7 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, fdst, fsrcfstest.CheckItems(t, r.Fremote, file1, file2r, file3)check(4, 1, 2, false)- r.WriteFile("empty space", "", t2)+ r.WriteFile("empty space", "-", t2)fstest.CheckItems(t, r.Flocal, file1, file2, file3)check(5, 0, 3, false)diff --git a/fs/sync/sync_test.go b/fs/sync/sync_test.goindex 95653ea69..231c2d24a 100644--- a/fs/sync/sync_test.go+++ b/fs/sync/sync_test.go@@ -289,7 +289,7 @@ func TestSyncBasedOnCheckSum(t *testing.T) {fs.Config.CheckSum = truedefer func() { fs.Config.CheckSum = false }()- file1 := r.WriteFile("check sum", "", t1)+ file1 := r.WriteFile("check sum", "-", t1)fstest.CheckItems(t, r.Flocal, file1)accounting.Stats.ResetCounters()@@ -301,7 +301,7 @@ func TestSyncBasedOnCheckSum(t *testing.T) {fstest.CheckItems(t, r.Fremote, file1)// Change last modified date only- file2 := r.WriteFile("check sum", "", t2)+ file2 := r.WriteFile("check sum", "-", t2)fstest.CheckItems(t, r.Flocal, file2)accounting.Stats.ResetCounters()@@ -509,8 +509,8 @@ func TestSyncIgnoreErrors(t *testing.T) {func TestSyncAfterChangingModtimeOnly(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()- file1 := r.WriteFile("empty space", "", t2)- file2 := r.WriteObject(context.Background(), "empty space", "", t1)+ file1 := r.WriteFile("empty space", "-", t2)+ file2 := r.WriteObject(context.Background(), "empty space", "-", t1)fstest.CheckItems(t, r.Flocal, file1)fstest.CheckItems(t, r.Fremote, file2)@@ -549,8 +549,8 @@ func TestSyncAfterChangingModtimeOnlyWithNoUpdateModTime(t *testing.T) {fs.Config.NoUpdateModTime = false}()- file1 := r.WriteFile("empty space", "", t2)- file2 := r.WriteObject(context.Background(), "empty space", "", t1)+ file1 := r.WriteFile("empty space", "-", t2)+ file2 := r.WriteObject(context.Background(), "empty space", "-", t1)fstest.CheckItems(t, r.Flocal, file1)fstest.CheckItems(t, r.Fremote, file2)@@ -590,7 +590,7 @@ func TestSyncDoesntUpdateModtime(t *testing.T) {func TestSyncAfterAddingAFile(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()- file1 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file1 := r.WriteBoth(context.Background(), "empty space", "-", t2)file2 := r.WriteFile("potato", "------------------------------------------------------------", t3)fstest.CheckItems(t, r.Flocal, file1, file2)@@ -647,7 +647,7 @@ func TestSyncAfterRemovingAFileAndAddingAFileDryRun(t *testing.T) {defer r.Finalise()file1 := r.WriteFile("potato2", "------------------------------------------------------------", t1)file2 := r.WriteObject(context.Background(), "potato", "SMALLER BUT SAME DATE", t2)- file3 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file3 := r.WriteBoth(context.Background(), "empty space", "-", t2)fs.Config.DryRun = trueaccounting.Stats.ResetCounters()@@ -665,7 +665,7 @@ func TestSyncAfterRemovingAFileAndAddingAFile(t *testing.T) {defer r.Finalise()file1 := r.WriteFile("potato2", "------------------------------------------------------------", t1)file2 := r.WriteObject(context.Background(), "potato", "SMALLER BUT SAME DATE", t2)- file3 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file3 := r.WriteBoth(context.Background(), "empty space", "-", t2)fstest.CheckItems(t, r.Fremote, file2, file3)fstest.CheckItems(t, r.Flocal, file1, file3)@@ -875,7 +875,7 @@ func TestSyncWithExclude(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1)- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)file3 := r.WriteFile("enormous", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytesfstest.CheckItems(t, r.Fremote, file1, file2)fstest.CheckItems(t, r.Flocal, file1, file2, file3)@@ -903,7 +903,7 @@ func TestSyncWithExcludeAndDeleteExcluded(t *testing.T) {r := fstest.NewRun(t)defer r.Finalise()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1) // 60 bytes- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)file3 := r.WriteBoth(context.Background(), "enormous", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytesfstest.CheckItems(t, r.Fremote, file1, file2, file3)fstest.CheckItems(t, r.Flocal, file1, file2, file3)@@ -1017,7 +1017,7 @@ func testServerSideMove(t *testing.T, r *fstest.Run, withFilter, testDeleteEmptydefer finaliseMove()file1 := r.WriteBoth(context.Background(), "potato2", "------------------------------------------------------------", t1)- file2 := r.WriteBoth(context.Background(), "empty space", "", t2)+ file2 := r.WriteBoth(context.Background(), "empty space", "-", t2)file3u := r.WriteBoth(context.Background(), "potato3", "------------------------------------------------------------ UPDATED", t2)if testDeleteEmptyDirs {@@ -1030,7 +1030,7 @@ func testServerSideMove(t *testing.T, r *fstest.Run, withFilter, testDeleteEmptyt.Logf("Server side move (if possible) %v -> %v", r.Fremote, FremoteMove)// Write just one file in the new remote- r.WriteObjectTo(context.Background(), FremoteMove, "empty space", "", t2, false)+ r.WriteObjectTo(context.Background(), FremoteMove, "empty space", "-", t2, false)file3 := r.WriteObjectTo(context.Background(), FremoteMove, "potato3", "------------------------------------------------------------", t1, false)fstest.CheckItems(t, FremoteMove, file2, file3)