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

Function TestTrackerRegistrationLookup

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

Source from the content-addressed store, hash-verified

330}
331
332func TestTrackerRegistrationLookup(t *testing.T) {
333 tracker := newAsyncCallStateTracker()
334 completions := make(chan int64, 2)
335 gate := newAsyncGate(0, completions)
336 impl := asyncReturning(types.Int(1), nil)
337
338 a := tracker.getOrCreate(1, "fn", "a", []ref.Val{types.Int(1)}, impl, gate)
339 b := tracker.getOrCreate(2, "fn", "b", []ref.Val{types.Int(2)}, impl, gate)
340
341 // Registered calls must be retrievable by callID.
342 for _, want := range []*asyncCallState{a, b} {
343 if got := tracker.getByID(want.CallID()); got != want {
344 t.Errorf("getByID(%d) returned a different call record", want.CallID())
345 }
346 }
347 // Unknown callIDs resolve to nil rather than panicking.
348 if got := tracker.getByID(99999); got != nil {
349 t.Errorf("getByID(unknown) = %v, wanted nil", got)
350 }
351}
352
353func TestAsyncObserverLifecycle(t *testing.T) {
354 ctx, cancel := context.WithCancel(context.Background())

Callers

nothing calls this directly

Calls 7

IntTypeAlias · 0.92
newAsyncCallStateTrackerFunction · 0.85
newAsyncGateFunction · 0.85
asyncReturningFunction · 0.85
getOrCreateMethod · 0.80
getByIDMethod · 0.80
CallIDMethod · 0.65

Tested by

no test coverage detected