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

Function TestAsyncTrackerPoolReleaseClearsState

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

Source from the content-addressed store, hash-verified

604}
605
606func TestAsyncTrackerPoolReleaseClearsState(t *testing.T) {
607 tracker := newAsyncCallStateTracker()
608 completions := make(chan int64, 4)
609 gate := newAsyncGate(0, completions)
610 for i := int64(1); i <= 3; i++ {
611 tracker.getOrCreate(i, "fn", "ov", []ref.Val{types.Int(i)}, asyncReturning(types.Int(i), nil), gate)
612 }
613 if tracker.getByID(2) == nil {
614 t.Fatal("getByID(2) = nil before release, wanted a call record")
615 }
616
617 asyncCallStateTrackerPool.release(tracker)
618
619 if got := len(tracker.calls); got != 0 {
620 t.Errorf("calls map size after release = %d, wanted 0", got)
621 }
622 if got := len(tracker.callsByID); got != 0 {
623 t.Errorf("callsByID map size after release = %d, wanted 0", got)
624 }
625 if got := tracker.nextCallID.Load(); got != 0 {
626 t.Errorf("nextCallID after release = %d, wanted 0", got)
627 }
628 // A released tracker is safe to reuse: callIDs restart and bookkeeping is fresh.
629 acs := tracker.getOrCreate(1, "fn", "ov", []ref.Val{types.Int(1)}, asyncReturning(types.Int(1), nil), gate)
630 if acs.CallID() != 1 {
631 t.Errorf("reused tracker assigned callID %d, wanted 1", acs.CallID())
632 }
633}
634
635func TestAsyncCallStateMatches(t *testing.T) {
636 mk := func(fn, ov string, args ...ref.Val) *asyncCallState {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected