MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestRetryMaxAttemptsExhausted

Function TestRetryMaxAttemptsExhausted

cel/async/async_test.go:81–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func 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
101func TestRetryBindingCancellation(t *testing.T) {
102 var attempts atomic.Int32

Callers

nothing calls this directly

Calls 9

RetryBindingFunction · 0.92
WrapErrFunction · 0.92
RetryAttemptsFunction · 0.92
RetryBackoffFunction · 0.92
IsErrorFunction · 0.92
buildZeroArgAsyncFunction · 0.85
AddMethod · 0.65
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected