Skip to content

Commit 6df1959

Browse files
committed
chore: fix TestMeasureLatency/MeasureLatencyRecvTimeout flake
1 parent a0fce36 commit 6df1959

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

coderd/database/pubsub/pubsub_linux_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,12 @@ func TestMeasureLatency(t *testing.T) {
342342
ps, done := newPubsub()
343343
defer done()
344344

345-
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(-time.Hour))
346-
defer cancel()
345+
ctx, cancel := context.WithCancel(context.Background())
346+
cancel()
347347

348+
<-ctx.Done()
348349
send, recv, err := pubsub.NewLatencyMeasurer(logger).Measure(ctx, ps)
349-
require.ErrorContains(t, err, context.DeadlineExceeded.Error())
350+
require.ErrorContains(t, err, context.Canceled.Error())
350351
require.Greater(t, send.Seconds(), 0.0)
351352
require.EqualValues(t, recv, time.Duration(-1))
352353
})

0 commit comments

Comments
 (0)