chore: update testutil chan helpers (#17408)

This commit is contained in:
ケイラ
2025-04-16 10:37:09 -06:00
committed by GitHub
parent 2a76f5028e
commit f670bc31f5
45 changed files with 582 additions and 559 deletions
+7 -7
View File
@@ -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)
}