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

Function TestAsyncTrackerPoolReleaseClearsState

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

Source from the content-addressed store, hash-verified

681}
682
683func TestAsyncTrackerPoolReleaseClearsState(t *testing.T) {
684 tracker := newAsyncCallStateTracker()
685 completions := make(chan int64, 4)
686 gate := newAsyncGate(0, completions)
687 for i := int64(1); i <= 3; i++ {
688 tracker.getOrCreate(i, "fn", "ov", []ref.Val{types.Int(i)}, asyncReturning(types.Int(i), nil), gate)
689 }
690 if tracker.getByID(2) == nil {
691 t.Fatal("getByID(2) = nil before release, wanted a call record")
692 }
693
694 asyncCallStateTrackerPool.release(tracker)
695
696 if got := len(tracker.calls); got != 0 {
697 t.Errorf("calls map size after release = %d, wanted 0", got)
698 }
699 if got := len(tracker.callsByID); got != 0 {
700 t.Errorf("callsByID map size after release = %d, wanted 0", got)
701 }
702 if got := tracker.nextCallID.Load(); got != 0 {
703 t.Errorf("nextCallID after release = %d, wanted 0", got)
704 }
705 // A released tracker is safe to reuse: callIDs restart and bookkeeping is fresh.
706 acs := tracker.getOrCreate(1, "fn", "ov", []ref.Val{types.Int(1)}, asyncReturning(types.Int(1), nil), gate)
707 if acs.CallID() != 1 {
708 t.Errorf("reused tracker assigned callID %d, wanted 1", acs.CallID())
709 }
710}
711
712func TestAsyncCallStateMatches(t *testing.T) {
713 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
releaseMethod · 0.80
CallIDMethod · 0.65

Tested by

no test coverage detected