(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func TestRetryMaxAttemptsExhausted(t *testing.T) { |
| 82 | var attempts atomic.Int32 |
| 83 | op := buildZeroArgAsync(t, async.RetryBinding(func(ctx context.Context, args ...ref.Val) ref.Val { |
| 84 | a := attempts.Add(1) |
| 85 | return types.WrapErr(fmt.Errorf("retry attempt %d failed: %w", a, retryableTestErr{})) |
| 86 | }, async.RetryAttempts(3), async.RetryBackoff(5*time.Millisecond))) |
| 87 | |
| 88 | res := <-op(context.Background()) |
| 89 | if !types.IsError(res) { |
| 90 | t.Fatalf("result = %v, want error", res) |
| 91 | } |
| 92 | msg := res.(*types.Err).Error() |
| 93 | if !strings.Contains(msg, "retry attempt 3 failed") { |
| 94 | t.Errorf("result error = %q, want last error 'retry attempt 3 failed'", msg) |
| 95 | } |
| 96 | if got := attempts.Load(); got != 3 { |
| 97 | t.Errorf("attempts = %d, want 3", got) |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | func TestRetryBindingCancellation(t *testing.T) { |
| 102 | var attempts atomic.Int32 |
nothing calls this directly
no test coverage detected