"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
fstest: create AssertTimeEqualWithPrecision from CheckTimeEqualWithPrecision
Nick Craig-Woodbbb6f9437764
diff --git a/backend/http/http_internal_test.go b/backend/http/http_internal_test.goindex e89e58b7b..e62a02b98 100644--- a/backend/http/http_internal_test.go+++ b/backend/http/http_internal_test.go@@ -166,8 +166,7 @@ func TestNewObject(t *testing.T) {require.NoError(t, err)tFile := fi.ModTime()- dt, ok := fstest.CheckTimeEqualWithPrecision(tObj, tFile, time.Second)- assert.True(t, ok, fmt.Sprintf("%s: Modification time difference too big |%s| > %s (%s vs %s) (precision %s)", o.Remote(), dt, time.Second, tObj, tFile, time.Second))+ fstest.AssertTimeEqualWithPrecision(t, o.Remote(), tFile, tObj, time.Second)// check object not foundo, err = f.NewObject(context.Background(), "not found.txt")diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.goindex 3616a8db0..8b8cae348 100644--- a/fs/operations/operations_test.go+++ b/fs/operations/operations_test.go@@ -166,10 +166,7 @@ func TestLsLong(t *testing.T) {if err != nil {t.Errorf("Error parsing %q: %v", m, err)} else {- dt, ok := fstest.CheckTimeEqualWithPrecision(expected, modTime, precision)- if !ok {- t.Errorf("%s: Modification time difference too big |%s| > %s (%s vs %s) (precision %s)", filename, dt, precision, modTime, expected, precision)- }+ fstest.AssertTimeEqualWithPrecision(t, filename, expected, modTime, precision)}}diff --git a/fstest/fstest.go b/fstest/fstest.goindex 81eefc828..ec5242895 100644--- a/fstest/fstest.go+++ b/fstest/fstest.go@@ -117,10 +117,16 @@ func CheckTimeEqualWithPrecision(t0, t1 time.Time, precision time.Duration) (timreturn dt, true}+// AssertTimeEqualWithPrecision checks that want is within precision+// of got, asserting that with t and logging remote+func AssertTimeEqualWithPrecision(t *testing.T, remote string, want, got time.Time, precision time.Duration) {+ dt, ok := CheckTimeEqualWithPrecision(want, got, precision)+ assert.True(t, ok, fmt.Sprintf("%s: Modification time difference too big |%s| > %s (want %s vs got %s) (precision %s)", remote, dt, precision, want, got, precision))+}+// CheckModTime checks the mod time to the given precisionfunc (i *Item) CheckModTime(t *testing.T, obj fs.Object, modTime time.Time, precision time.Duration) {- dt, ok := CheckTimeEqualWithPrecision(modTime, i.ModTime, precision)- assert.True(t, ok, fmt.Sprintf("%s: Modification time difference too big |%s| > %s (%s vs %s) (precision %s)", obj.Remote(), dt, precision, modTime, i.ModTime, precision))+ AssertTimeEqualWithPrecision(t, obj.Remote(), i.ModTime, modTime, precision)}// CheckHashes checks all the hashes the object supports are correct