Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fstest: add precision to CompareItems so it works on non-local remotes

Nick Craig-Wood743dabf159df
diff --git a/fs/march/march_test.go b/fs/march/march_test.go
index eae1ea86a..0a0ec940b 100644
--- a/fs/march/march_test.go
+++ b/fs/march/march_test.go
@@ -207,9 +207,10 @@ func TestMarch(t *testing.T) {
err := mt.currentError()
require.NoError(t, err)
- fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, "srcOnly")
- fstest.CompareItems(t, mt.dstOnly, dstOnly, test.dirDstOnly, "dstOnly")
- fstest.CompareItems(t, mt.match, match, test.dirMatch, "match")
+ precision := fs.GetModifyWindow(r.Fremote, r.Flocal)
+ fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, precision, "srcOnly")
+ fstest.CompareItems(t, mt.dstOnly, dstOnly, test.dirDstOnly, precision, "dstOnly")
+ fstest.CompareItems(t, mt.match, match, test.dirMatch, precision, "match")
})
}
}
@@ -273,8 +274,9 @@ func TestMarchNoTraverse(t *testing.T) {
err := mt.currentError()
require.NoError(t, err)
- fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, "srcOnly")
- fstest.CompareItems(t, mt.match, match, test.dirMatch, "match")
+ precision := fs.GetModifyWindow(r.Fremote, r.Flocal)
+ fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, precision, "srcOnly")
+ fstest.CompareItems(t, mt.match, match, test.dirMatch, precision, "match")
})
}
}
diff --git a/fstest/fstest.go b/fstest/fstest.go
index faf6a5134..9c4ae4c7d 100644
--- a/fstest/fstest.go
+++ b/fstest/fstest.go
@@ -348,10 +348,10 @@ func CheckItems(t *testing.T, f fs.Fs, items ...Item) {
CheckListingWithPrecision(t, f, items, nil, fs.GetModifyWindow(f))
}
-// CompareItems compares a set of DirEntries to a slice of items and a lit of dirs
-func CompareItems(t *testing.T, entries fs.DirEntries, items []Item, expectedDirs []string, what string) {
+// CompareItems compares a set of DirEntries to a slice of items and a list of dirs
+// The modtimes are compared with the precision supplied
+func CompareItems(t *testing.T, entries fs.DirEntries, items []Item, expectedDirs []string, precision time.Duration, what string) {
is := NewItems(items)
- precision, _ := time.ParseDuration("1s")
var objs []fs.Object
var dirs []fs.Directory
wantListing1, wantListing2 := makeListingFromItems(items)