From 257607ab3df3734cec1c4003975d83ca08e8dac5 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 5 Sep 2023 17:42:17 +0100 Subject: [PATCH] operations: fix TestCopyFileMaxTransfer test to not be quite so fussy --- fs/operations/operations_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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)