(t *testing.T)
| 428 | } |
| 429 | |
| 430 | func TestAsyncObserverLifecycle(t *testing.T) { |
| 431 | ctx, cancel := context.WithCancel(context.Background()) |
| 432 | defer cancel() |
| 433 | frame, closeFrame := newTestFrame(t, ctx) |
| 434 | defer closeFrame() |
| 435 | |
| 436 | obs := &recordingObserver{} |
| 437 | if err := frame.SetAsyncObserver(obs); err != nil { |
| 438 | t.Fatalf("SetAsyncObserver() failed: %v", err) |
| 439 | } |
| 440 | completions := make(chan int64, 1) |
| 441 | if err := frame.SetCompletions(completions); err != nil { |
| 442 | t.Fatalf("SetCompletions() failed: %v", err) |
| 443 | } |
| 444 | |
| 445 | awaitResult(t, frame, completions, 1, "fn", "fn_int", asyncReturning(types.Int(7), nil), types.Int(1)) |
| 446 | |
| 447 | if got := obs.started.Load(); got != 1 { |
| 448 | t.Errorf("OnCallStarted called %d times, wanted 1", got) |
| 449 | } |
| 450 | if got := obs.finished.Load(); got != 1 { |
| 451 | t.Errorf("OnCallFinished called %d times, wanted 1", got) |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | func TestAsyncObserverOnCancellation(t *testing.T) { |
| 456 | ctx, cancel := context.WithCancelCause(context.Background()) |
nothing calls this directly
no test coverage detected