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

Function TestComputeResultResolves

interpreter/async_test.go:104–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestComputeResultResolves(t *testing.T) {
105 ctx, cancel := context.WithCancel(context.Background())
106 defer cancel()
107 frame, closeFrame := newTestFrame(t, ctx)
108 defer closeFrame()
109
110 completions := make(chan int64, 1)
111 if err := frame.SetCompletions(completions); err != nil {
112 t.Fatalf("SetCompletions() failed: %v", err)
113 }
114
115 var calls atomic.Int32
116 impl := asyncReturning(types.Int(42), &calls)
117 res := awaitResult(t, frame, completions, 1, "fn", "fn_int", impl, types.Int(1))
118 if res.Equal(types.Int(42)) != types.True {
119 t.Errorf("async result = %v, wanted 42", res)
120 }
121 if got := calls.Load(); got != 1 {
122 t.Errorf("impl invoked %d times, wanted exactly 1", got)
123 }
124}
125
126func TestTrackerDedupAndCallIDs(t *testing.T) {
127 // Exercise the tracker directly to keep bookkeeping assertions isolated from the

Callers

nothing calls this directly

Calls 6

IntTypeAlias · 0.92
newTestFrameFunction · 0.85
asyncReturningFunction · 0.85
awaitResultFunction · 0.85
SetCompletionsMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected