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

Function TestConcurrentEvalAllowsPartialUnknown

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

Source from the content-addressed store, hash-verified

547}
548
549func TestConcurrentEvalAllowsPartialUnknown(t *testing.T) {
550 prg := mustProgram(t, `async_func(42) + x`,
551 cel.Variable("x", cel.IntType),
552 cel.Function("async_func",
553 cel.Overload("async_func_int", []*cel.Type{cel.IntType}, cel.IntType,
554 cel.AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
555 time.Sleep(5 * time.Millisecond)
556 return args[0]
557 }),
558 ),
559 ),
560 cel.EvalOptions(cel.OptPartialEval),
561 )
562 pvars, err := cel.PartialVars(map[string]any{}, cel.AttributePattern("x"))
563 if err != nil {
564 t.Fatalf("PartialVars() failed: %v", err)
565 }
566 res := awaitEval(t, prg, context.Background(), pvars)
567 if res.Err != nil {
568 t.Fatalf("ConcurrentEval() with partial unknown returned error: %v", res.Err)
569 }
570 if !types.IsUnknown(res.Val) {
571 t.Errorf("ConcurrentEval() = %v, want Unknown", res.Val)
572 }
573}
574
575func TestConcurrentEvalAsyncObserver(t *testing.T) {
576 obs := &countingObserver{}

Callers

nothing calls this directly

Calls 10

VariableFunction · 0.92
FunctionFunction · 0.92
OverloadFunction · 0.92
AsyncBindingFunction · 0.92
EvalOptionsFunction · 0.92
PartialVarsFunction · 0.92
AttributePatternFunction · 0.92
IsUnknownFunction · 0.92
mustProgramFunction · 0.85
awaitEvalFunction · 0.85

Tested by

no test coverage detected