(t *testing.T)
| 351 | } |
| 352 | |
| 353 | func TestAsyncObserverLifecycle(t *testing.T) { |
| 354 | ctx, cancel := context.WithCancel(context.Background()) |
| 355 | defer cancel() |
| 356 | frame, closeFrame := newTestFrame(t, ctx) |
| 357 | defer closeFrame() |
| 358 | |
| 359 | obs := &recordingObserver{} |
| 360 | if err := frame.SetAsyncObserver(obs); err != nil { |
| 361 | t.Fatalf("SetAsyncObserver() failed: %v", err) |
| 362 | } |
| 363 | completions := make(chan int64, 1) |
| 364 | if err := frame.SetCompletions(completions); err != nil { |
| 365 | t.Fatalf("SetCompletions() failed: %v", err) |
| 366 | } |
| 367 | |
| 368 | awaitResult(t, frame, completions, 1, "fn", "fn_int", asyncReturning(types.Int(7), nil), types.Int(1)) |
| 369 | |
| 370 | if got := obs.started.Load(); got != 1 { |
| 371 | t.Errorf("OnCallStarted called %d times, wanted 1", got) |
| 372 | } |
| 373 | if got := obs.finished.Load(); got != 1 { |
| 374 | t.Errorf("OnCallFinished called %d times, wanted 1", got) |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | func TestAsyncObserverOnCancellation(t *testing.T) { |
| 379 | ctx, cancel := context.WithCancelCause(context.Background()) |
nothing calls this directly
no test coverage detected