(t *testing.T)
| 547 | } |
| 548 | |
| 549 | func 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 | |
| 575 | func TestConcurrentEvalAsyncObserver(t *testing.T) { |
| 576 | obs := &countingObserver{} |
nothing calls this directly
no test coverage detected