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

Function TestConcurrentEvalPreCanceledContext

cel/program_async_test.go:757–773  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

755}
756
757func TestConcurrentEvalPreCanceledContext(t *testing.T) {
758 prg := mustProgram(t, `async_func(42)`,
759 cel.Function("async_func",
760 cel.Overload("async_func_int", []*cel.Type{cel.IntType}, cel.IntType,
761 cel.AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
762 return args[0]
763 }),
764 ),
765 ),
766 )
767 ctx, cancel := context.WithCancel(context.Background())
768 cancel()
769 res := <-prg.ConcurrentEval(ctx, cel.NoVars())
770 if res.Err == nil || !errors.Is(res.Err, context.Canceled) {
771 t.Errorf("ConcurrentEval() on pre-canceled context = %v, want context.Canceled", res.Err)
772 }
773}
774
775func TestSyncEvalRejectsAsyncBeforeEvaluating(t *testing.T) {
776 // The async guard must fire at the entry point, before any evaluation: the async function

Callers

nothing calls this directly

Calls 7

FunctionFunction · 0.92
OverloadFunction · 0.92
AsyncBindingFunction · 0.92
NoVarsFunction · 0.92
mustProgramFunction · 0.85
ConcurrentEvalMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected