(t *testing.T)
| 604 | } |
| 605 | |
| 606 | func 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 | |
| 635 | func TestAsyncCallStateMatches(t *testing.T) { |
| 636 | mk := func(fn, ov string, args ...ref.Val) *asyncCallState { |
nothing calls this directly
no test coverage detected