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

operations: fix TestCopyFileMaxTransfer test to not be quite so fussy

Nick Craig-Wood257607ab3df3
diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.go
index c3cb40911..640807ca2 100644
--- a/fs/operations/operations_test.go
+++ b/fs/operations/operations_test.go
@@ -38,7 +38,6 @@ import (
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/accounting"
"github.com/rclone/rclone/fs/filter"
- "github.com/rclone/rclone/fs/fserrors"
"github.com/rclone/rclone/fs/fshttp"
"github.com/rclone/rclone/fs/hash"
"github.com/rclone/rclone/fs/operations"
@@ -1919,8 +1918,13 @@ func TestCopyFileMaxTransfer(t *testing.T) {
accounting.Stats(ctx).ResetCounters()
err = operations.CopyFile(ctx, r.Fremote, r.Flocal, file2.Path, file2.Path)
require.NotNil(t, err, "Did not get expected max transfer limit error")
- assert.Contains(t, err.Error(), "max transfer limit reached")
- assert.True(t, fserrors.IsFatalError(err), fmt.Sprintf("Not fatal error: %v: %#v:", err, err))
+ if !errors.Is(err, accounting.ErrorMaxTransferLimitReachedFatal) {
+ t.Log("Expecting error to contain accounting.ErrorMaxTransferLimitReachedFatal")
+ // Sometimes the backends or their SDKs don't pass the
+ // error through properly, so check that it at least
+ // has the text we expect in.
+ assert.Contains(t, err.Error(), "max transfer limit reached")
+ }
r.CheckLocalItems(t, file1, file2, file3, file4)
r.CheckRemoteItems(t, file1)
@@ -1931,8 +1935,7 @@ func TestCopyFileMaxTransfer(t *testing.T) {
accounting.Stats(ctx).ResetCounters()
err = operations.CopyFile(ctx, r.Fremote, r.Flocal, file3.Path, file3.Path)
require.NotNil(t, err)
- assert.Contains(t, err.Error(), "max transfer limit reached")
- assert.True(t, fserrors.IsNoRetryError(err))
+ assert.True(t, errors.Is(err, accounting.ErrorMaxTransferLimitReachedGraceful))
r.CheckLocalItems(t, file1, file2, file3, file4)
r.CheckRemoteItems(t, file1)