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

Function TestRetryNonRetryableError

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

Source from the content-addressed store, hash-verified

130}
131
132func TestRetryNonRetryableError(t *testing.T) {
133 var attempts atomic.Int32
134 op := buildZeroArgAsync(t, async.RetryBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
135 attempts.Add(1)
136 return types.WrapErr(nonRetryableTestErr{})
137 }, async.RetryAttempts(5), async.RetryBackoff(10*time.Millisecond)))
138
139 res := <-op(context.Background())
140 if !types.IsError(res) || !strings.Contains(res.(*types.Err).Error(), "do not retry me") {
141 t.Fatalf("result = %v, want 'do not retry me'", res)
142 }
143 if got := attempts.Load(); got != 1 {
144 t.Errorf("attempts = %d, want 1 (non-retryable error should not be retried)", got)
145 }
146}
147
148func TestRetryStandardError(t *testing.T) {
149 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