@@ -132,6 +132,16 @@ func TestIsRetryable(t *testing.T) {
132132 err : fmt .Errorf ("operation failed: %w" , context .Canceled ),
133133 want : false ,
134134 },
135+ {
136+ name : "context.DeadlineExceeded" ,
137+ err : context .DeadlineExceeded ,
138+ want : false ,
139+ },
140+ {
141+ name : "wrapped context.DeadlineExceeded" ,
142+ err : fmt .Errorf ("operation timed out: %w" , context .DeadlineExceeded ),
143+ want : false ,
144+ },
135145 {
136146 name : "HTTP 500 server error" ,
137147 err : fmt .Errorf ("PUT /blobs/uploads: response status code 500: internal server error" ),
@@ -344,6 +354,7 @@ func TestDo_RetryOnTransientError(t *testing.T) {
344354 }, DoOpts {
345355 FileSize : 100 ,
346356 FileName : "test.bin" ,
357+ Config : & Config {InitialDelay : 10 * time .Millisecond , MaxJitter : - 1 },
347358 })
348359
349360 if err != nil {
@@ -406,6 +417,7 @@ func TestDo_ParentContextCancel(t *testing.T) {
406417 }, DoOpts {
407418 FileSize : 100 ,
408419 FileName : "test.bin" ,
420+ Config : & Config {InitialDelay : 10 * time .Millisecond , MaxJitter : - 1 },
409421 })
410422
411423 if err == nil {
@@ -427,6 +439,7 @@ func TestDo_OnRetryCallback(t *testing.T) {
427439 }, DoOpts {
428440 FileSize : 100 ,
429441 FileName : "test.bin" ,
442+ Config : & Config {InitialDelay : 10 * time .Millisecond , MaxJitter : - 1 },
430443 OnRetry : func (attempt uint , reason string , backoff time.Duration ) {
431444 retryAttempts = append (retryAttempts , attempt )
432445 retryReasons = append (retryReasons , reason )
@@ -458,7 +471,9 @@ func TestDo_ConfigMaxRetryTimeOverride(t *testing.T) {
458471 FileSize : 100 ,
459472 FileName : "test.bin" ,
460473 Config : & Config {
461- MaxRetryTime : 8 * time .Second ,
474+ MaxRetryTime : 1 * time .Second ,
475+ InitialDelay : 50 * time .Millisecond ,
476+ MaxJitter : - 1 ,
462477 },
463478 })
464479
@@ -467,9 +482,9 @@ func TestDo_ConfigMaxRetryTimeOverride(t *testing.T) {
467482 if err == nil {
468483 t .Fatal ("expected error after retry timeout, got nil" )
469484 }
470- // Should have run for approximately MaxRetryTime (8s ), not the dynamic default (10min).
471- if elapsed > 30 * time .Second {
472- t .Errorf ("expected retry to terminate within ~8s , but elapsed %v" , elapsed )
485+ // Should have run for approximately MaxRetryTime (1s ), not the dynamic default (10min).
486+ if elapsed > 5 * time .Second {
487+ t .Errorf ("expected retry to terminate within ~1s , but elapsed %v" , elapsed )
473488 }
474489 if atomic .LoadInt32 (& callCount ) < 2 {
475490 t .Errorf ("expected at least 2 attempts, got %d" , callCount )
0 commit comments