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

Function TestConcurrentEval

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

Source from the content-addressed store, hash-verified

35)
36
37func TestConcurrentEval(t *testing.T) {
38 cases := []struct {
39 name string
40 expr string
41 vars any
42 opts []any
43 maxConc int
44 want any
45 wantLaunches int32
46 trackCost bool
47 trackState bool
48 wantErr string
49 wantCost uint64
50 leakCheck bool
51 }{
52 {
53 name: "sync_eval",
54 expr: `x + 1`,
55 vars: map[string]any{"x": 10},
56 opts: []any{cel.Variable("x", cel.IntType)},
57 want: 11,
58 },
59 {
60 name: "single_async",
61 expr: `async_func(42) + 1`,
62 opts: []any{
63 cel.Function("async_func",
64 cel.Overload("async_func_int", []*cel.Type{cel.IntType}, cel.IntType,
65 cel.AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
66 time.Sleep(1 * time.Millisecond)
67 return args[0]
68 }),
69 ),
70 ),
71 },
72 want: 43,
73 },
74 {
75 name: "completion_buffer_size",
76 expr: `async_func(42) + 1`,
77 opts: []any{
78 cel.Function("async_func",
79 cel.Overload("async_func_int", []*cel.Type{cel.IntType}, cel.IntType,
80 cel.AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
81 time.Sleep(1 * time.Millisecond)
82 return args[0]
83 }),
84 ),
85 ),
86 cel.AsyncCompletionBufferSize(16),
87 },
88 want: 43,
89 },
90 {
91 name: "outside_parallel_conc_1",
92 expr: `async_inc(10) + async_inc(20)`,
93 maxConc: 1,
94 want: 32,

Callers

nothing calls this directly

Calls 15

VariableFunction · 0.92
FunctionFunction · 0.92
OverloadFunction · 0.92
AsyncBindingFunction · 0.92
FakeRPCFunction · 0.92
ConcurrentDrainStrategyFunction · 0.92
DrainAllFunction · 0.92
DrainReadyFunction · 0.92
DrainNoneFunction · 0.92
EvalOptionsFunction · 0.92
ListsFunction · 0.92

Tested by

no test coverage detected