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

Function TestConcurrentEvalPreCanceledContext

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

Source from the content-addressed store, hash-verified

638}
639
640func TestConcurrentEvalPreCanceledContext(t *testing.T) {
641 prg := mustProgram(t, `async_func(42)`,
642 cel.Function("async_func",
643 cel.Overload("async_func_int", []*cel.Type{cel.IntType}, cel.IntType,
644 cel.AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
645 return args[0]
646 }),
647 ),
648 ),
649 )
650 ctx, cancel := context.WithCancel(context.Background())
651 cancel()
652 res := <-prg.ConcurrentEval(ctx, cel.NoVars())
653 if res.Err == nil || !errors.Is(res.Err, context.Canceled) {
654 t.Errorf("ConcurrentEval() on pre-canceled context = %v, want context.Canceled", res.Err)
655 }
656}
657
658func TestSyncEvalRejectsAsyncBeforeEvaluating(t *testing.T) {
659 // 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