@@ -450,10 +450,10 @@ func mockTelemetryServer(ctx context.Context, t *testing.T) (*url.URL, chan *tel
450
450
dd := & telemetry.Deployment {}
451
451
err := json .NewDecoder (r .Body ).Decode (dd )
452
452
require .NoError (t , err )
453
- select {
454
- case <- ctx . Done ():
455
- t . Fatal ( "timed out sending deployment" )
456
- case deployment <- dd :
453
+ ok := testutil . AssertSend ( ctx , t , deployment , dd )
454
+ if ! ok {
455
+ w . WriteHeader ( http . StatusInternalServerError )
456
+ return
457
457
}
458
458
// Ensure the header is sent only after deployment is sent
459
459
w .WriteHeader (http .StatusAccepted )
@@ -463,10 +463,10 @@ func mockTelemetryServer(ctx context.Context, t *testing.T) (*url.URL, chan *tel
463
463
ss := & telemetry.Snapshot {}
464
464
err := json .NewDecoder (r .Body ).Decode (ss )
465
465
require .NoError (t , err )
466
- select {
467
- case <- ctx . Done ():
468
- t . Fatal ( "timed out sending snapshot" )
469
- case snapshot <- ss :
466
+ ok := testutil . AssertSend ( ctx , t , snapshot , ss )
467
+ if ! ok {
468
+ w . WriteHeader ( http . StatusInternalServerError )
469
+ return
470
470
}
471
471
// Ensure the header is sent only after snapshot is sent
472
472
w .WriteHeader (http .StatusAccepted )
@@ -487,7 +487,7 @@ func collectSnapshot(
487
487
) (* telemetry.Deployment , * telemetry.Snapshot ) {
488
488
t .Helper ()
489
489
490
- serverURL , deploymentChan , snapshotChan := mockTelemetryServer (ctx , t )
490
+ serverURL , deployment , snapshot := mockTelemetryServer (ctx , t )
491
491
492
492
options := telemetry.Options {
493
493
Database : db ,
@@ -503,19 +503,5 @@ func collectSnapshot(
503
503
require .NoError (t , err )
504
504
t .Cleanup (reporter .Close )
505
505
506
- var deployment * telemetry.Deployment
507
- var snapshot * telemetry.Snapshot
508
-
509
- select {
510
- case <- ctx .Done ():
511
- t .Fatal ("timed out collecting deployment" )
512
- case deployment = <- deploymentChan :
513
- }
514
- select {
515
- case <- ctx .Done ():
516
- t .Fatal ("timed out collecting snapshot" )
517
- case snapshot = <- snapshotChan :
518
- }
519
-
520
- return deployment , snapshot
506
+ return testutil .RequireReceive (ctx , t , deployment ), testutil .RequireReceive (ctx , t , snapshot )
521
507
}
0 commit comments