mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: update testutil chan helpers (#17408)
This commit is contained in:
@@ -60,7 +60,7 @@ func TestPGPubsub_Metrics(t *testing.T) {
|
||||
err := uut.Publish(event, []byte(data))
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
_ = testutil.RequireRecvCtx(ctx, t, messageChannel)
|
||||
_ = testutil.TryReceive(ctx, t, messageChannel)
|
||||
|
||||
require.Eventually(t, func() bool {
|
||||
latencyBytes := gatherCount * pubsub.LatencyMessageLength
|
||||
@@ -96,8 +96,8 @@ func TestPGPubsub_Metrics(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
// should get 2 messages because we have 2 subs
|
||||
_ = testutil.RequireRecvCtx(ctx, t, messageChannel)
|
||||
_ = testutil.RequireRecvCtx(ctx, t, messageChannel)
|
||||
_ = testutil.TryReceive(ctx, t, messageChannel)
|
||||
_ = testutil.TryReceive(ctx, t, messageChannel)
|
||||
|
||||
require.Eventually(t, func() bool {
|
||||
latencyBytes := gatherCount * pubsub.LatencyMessageLength
|
||||
@@ -167,10 +167,10 @@ func TestPGPubsubDriver(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// wait for the message
|
||||
_ = testutil.RequireRecvCtx(ctx, t, gotChan)
|
||||
_ = testutil.TryReceive(ctx, t, gotChan)
|
||||
|
||||
// read out first connection
|
||||
firstConn := testutil.RequireRecvCtx(ctx, t, subDriver.Connections)
|
||||
firstConn := testutil.TryReceive(ctx, t, subDriver.Connections)
|
||||
|
||||
// drop the underlying connection being used by the pubsub
|
||||
// the pq.Listener should reconnect and repopulate it's listeners
|
||||
@@ -179,7 +179,7 @@ func TestPGPubsubDriver(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// wait for the reconnect
|
||||
_ = testutil.RequireRecvCtx(ctx, t, subDriver.Connections)
|
||||
_ = testutil.TryReceive(ctx, t, subDriver.Connections)
|
||||
// we need to sleep because the raw connection notification
|
||||
// is sent before the pq.Listener can reestablish it's listeners
|
||||
time.Sleep(1 * time.Second)
|
||||
@@ -189,5 +189,5 @@ func TestPGPubsubDriver(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// wait for the message on the old subscription
|
||||
_ = testutil.RequireRecvCtx(ctx, t, gotChan)
|
||||
_ = testutil.TryReceive(ctx, t, gotChan)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user