(t *testing.T)
| 681 | } |
| 682 | |
| 683 | func 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 | |
| 712 | func TestAsyncCallStateMatches(t *testing.T) { |
| 713 | mk := func(fn, ov string, args ...ref.Val) *asyncCallState { |
nothing calls this directly
no test coverage detected