sync/operations: don't use zero length files in tests
We now have a backend (fichier) which doesn't support 0 length files. Therefore all 0 length files in the tests have been replaced with length 1. In a future commit we will implement a test for 0 length files.
This commit is contained in:
parent
6cd7c3b774
commit
38ebdf54be
3 changed files with 27 additions and 27 deletions
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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, fsrc
|
|||
fstest.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, fsrc
|
|||
fstest.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)
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ func TestSyncBasedOnCheckSum(t *testing.T) {
|
|||
fs.Config.CheckSum = true
|
||||
defer 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 = true
|
||||
accounting.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 bytes
|
||||
fstest.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 bytes
|
||||
fstest.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, testDeleteEmpty
|
|||
defer 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, testDeleteEmpty
|
|||
t.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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue