(t *testing.T)
| 330 | } |
| 331 | |
| 332 | func 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 | |
| 353 | func TestAsyncObserverLifecycle(t *testing.T) { |
| 354 | ctx, cancel := context.WithCancel(context.Background()) |
nothing calls this directly
no test coverage detected