mirror of
https://github.com/rclone/rclone.git
synced 2025-08-15 16:22:47 +02:00
🧪 fstest: fix time tests on Windows and add convenience methods to check local and remote fs with precision
Previously only the fs being checked on gets passed to GetModifyWindow(). However, in most tests, the test files are generated in the local fs and transferred to the remote fs. So the local fs time precision has to be taken into account. This meant that on Windows the time tests failed because the local fs has a time precision of 100ns. Checking remote items uploaded from local fs on Windows also requires a modify window of 100ns.
This commit is contained in:
@ -99,8 +99,8 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operat
|
||||
}
|
||||
|
||||
file1 := r.WriteBoth(ctx, "rutabaga", "is tasty", t3)
|
||||
fstest.CheckItems(t, r.Fremote, file1)
|
||||
fstest.CheckItems(t, r.Flocal, file1)
|
||||
r.CheckRemoteItems(t, file1)
|
||||
r.CheckLocalItems(t, file1)
|
||||
check(1, 0, 1, false, map[string]string{
|
||||
"combined": "= rutabaga\n",
|
||||
"missingonsrc": "",
|
||||
@ -111,7 +111,7 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operat
|
||||
})
|
||||
|
||||
file2 := r.WriteFile("potato2", "------------------------------------------------------------", t1)
|
||||
fstest.CheckItems(t, r.Flocal, file1, file2)
|
||||
r.CheckLocalItems(t, file1, file2)
|
||||
check(2, 1, 1, false, map[string]string{
|
||||
"combined": "+ potato2\n= rutabaga\n",
|
||||
"missingonsrc": "",
|
||||
@ -122,7 +122,7 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operat
|
||||
})
|
||||
|
||||
file3 := r.WriteObject(ctx, "empty space", "-", t2)
|
||||
fstest.CheckItems(t, r.Fremote, file1, file3)
|
||||
r.CheckRemoteItems(t, file1, file3)
|
||||
check(3, 2, 1, false, map[string]string{
|
||||
"combined": "- empty space\n+ potato2\n= rutabaga\n",
|
||||
"missingonsrc": "empty space\n",
|
||||
@ -138,7 +138,7 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operat
|
||||
} else {
|
||||
r.WriteObject(ctx, "potato2", "------------------------------------------------------------", t1)
|
||||
}
|
||||
fstest.CheckItems(t, r.Fremote, file1, file2r, file3)
|
||||
r.CheckRemoteItems(t, file1, file2r, file3)
|
||||
check(4, 1, 2, false, map[string]string{
|
||||
"combined": "- empty space\n= potato2\n= rutabaga\n",
|
||||
"missingonsrc": "empty space\n",
|
||||
@ -150,7 +150,7 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operat
|
||||
|
||||
file3r := file3
|
||||
file3l := r.WriteFile("empty space", "DIFFER", t2)
|
||||
fstest.CheckItems(t, r.Flocal, file1, file2, file3l)
|
||||
r.CheckLocalItems(t, file1, file2, file3l)
|
||||
check(5, 1, 3, false, map[string]string{
|
||||
"combined": "* empty space\n= potato2\n= rutabaga\n",
|
||||
"missingonsrc": "",
|
||||
@ -161,7 +161,7 @@ func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operat
|
||||
})
|
||||
|
||||
file4 := r.WriteObject(ctx, "remotepotato", "------------------------------------------------------------", t1)
|
||||
fstest.CheckItems(t, r.Fremote, file1, file2r, file3r, file4)
|
||||
r.CheckRemoteItems(t, file1, file2r, file3r, file4)
|
||||
check(6, 2, 3, false, map[string]string{
|
||||
"combined": "* empty space\n= potato2\n= rutabaga\n- remotepotato\n",
|
||||
"missingonsrc": "remotepotato\n",
|
||||
@ -440,7 +440,7 @@ func testCheckSum(t *testing.T, download bool) {
|
||||
fcsums := makeSums(operations.HashSums{
|
||||
"banana": testDigest1,
|
||||
})
|
||||
fstest.CheckItems(t, r.Fremote, fcsums, file1)
|
||||
r.CheckRemoteItems(t, fcsums, file1)
|
||||
check(1, 1, 0, wantType{
|
||||
"combined": "= banana\n",
|
||||
"missingonsrc": "",
|
||||
@ -454,7 +454,7 @@ func testCheckSum(t *testing.T, download bool) {
|
||||
fcsums = makeSums(operations.HashSums{
|
||||
"banana": testDigest1,
|
||||
})
|
||||
fstest.CheckItems(t, r.Fremote, fcsums, file1, file2)
|
||||
r.CheckRemoteItems(t, fcsums, file1, file2)
|
||||
check(2, 2, 1, wantType{
|
||||
"combined": "- potato\n= banana\n",
|
||||
"missingonsrc": "potato\n",
|
||||
@ -468,7 +468,7 @@ func testCheckSum(t *testing.T, download bool) {
|
||||
"banana": testDigest1,
|
||||
"potato": testDigest2,
|
||||
})
|
||||
fstest.CheckItems(t, r.Fremote, fcsums, file1, file2)
|
||||
r.CheckRemoteItems(t, fcsums, file1, file2)
|
||||
check(3, 2, 0, wantType{
|
||||
"combined": "= potato\n= banana\n",
|
||||
"missingonsrc": "",
|
||||
@ -482,7 +482,7 @@ func testCheckSum(t *testing.T, download bool) {
|
||||
"banana": testDigest2,
|
||||
"potato": testDigest2,
|
||||
})
|
||||
fstest.CheckItems(t, r.Fremote, fcsums, file1, file2)
|
||||
r.CheckRemoteItems(t, fcsums, file1, file2)
|
||||
check(4, 2, 1, wantType{
|
||||
"combined": "* banana\n= potato\n",
|
||||
"missingonsrc": "",
|
||||
@ -497,7 +497,7 @@ func testCheckSum(t *testing.T, download bool) {
|
||||
"potato": testDigest2,
|
||||
"orange": testDigest2,
|
||||
})
|
||||
fstest.CheckItems(t, r.Fremote, fcsums, file1, file2)
|
||||
r.CheckRemoteItems(t, fcsums, file1, file2)
|
||||
check(5, 2, 1, wantType{
|
||||
"combined": "+ orange\n= potato\n= banana\n",
|
||||
"missingonsrc": "",
|
||||
@ -512,7 +512,7 @@ func testCheckSum(t *testing.T, download bool) {
|
||||
"potato": testDigest1,
|
||||
"orange": testDigest2,
|
||||
})
|
||||
fstest.CheckItems(t, r.Fremote, fcsums, file1, file2)
|
||||
r.CheckRemoteItems(t, fcsums, file1, file2)
|
||||
check(6, 2, 2, wantType{
|
||||
"combined": "+ orange\n* potato\n= banana\n",
|
||||
"missingonsrc": "",
|
||||
@ -529,7 +529,7 @@ func testCheckSum(t *testing.T, download bool) {
|
||||
"banana": testDigest1Upper,
|
||||
"potato": testDigest2Mixed,
|
||||
})
|
||||
fstest.CheckItems(t, r.Fremote, fcsums, file1, file2)
|
||||
r.CheckRemoteItems(t, fcsums, file1, file2)
|
||||
check(7, 2, 0, wantType{
|
||||
"combined": "= banana\n= potato\n",
|
||||
"missingonsrc": "",
|
||||
|
Reference in New Issue
Block a user