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
+1 -1
View File
@@ -155,7 +155,7 @@ func TestBuildPayload(t *testing.T) {
require.NoError(t, err)
// THEN: expect that a payload will be constructed and have the expected values
payload := testutil.RequireRecvCtx(ctx, t, interceptor.payload)
payload := testutil.TryReceive(ctx, t, interceptor.payload)
require.Len(t, payload.Actions, 1)
require.Equal(t, label, payload.Actions[0].Label)
require.Equal(t, url, payload.Actions[0].URL)
+2 -2
View File
@@ -300,9 +300,9 @@ func TestPendingUpdatesMetric(t *testing.T) {
mClock.Advance(cfg.StoreSyncInterval.Value() - cfg.FetchInterval.Value()).MustWait(ctx)
// Wait until we intercept the calls to sync the pending updates to the store.
success := testutil.RequireRecvCtx(testutil.Context(t, testutil.WaitShort), t, interceptor.updateSuccess)
success := testutil.TryReceive(testutil.Context(t, testutil.WaitShort), t, interceptor.updateSuccess)
require.EqualValues(t, 2, success)
failure := testutil.RequireRecvCtx(testutil.Context(t, testutil.WaitShort), t, interceptor.updateFailure)
failure := testutil.TryReceive(testutil.Context(t, testutil.WaitShort), t, interceptor.updateFailure)
require.EqualValues(t, 2, failure)
// Validate that the store synced the expected number of updates.
+5 -5
View File
@@ -260,7 +260,7 @@ func TestWebhookDispatch(t *testing.T) {
mgr.Run(ctx)
// THEN: the webhook is received by the mock server and has the expected contents
payload := testutil.RequireRecvCtx(testutil.Context(t, testutil.WaitShort), t, sent)
payload := testutil.TryReceive(testutil.Context(t, testutil.WaitShort), t, sent)
require.EqualValues(t, "1.1", payload.Version)
require.Equal(t, msgID[0], payload.MsgID)
require.Equal(t, payload.Payload.Labels, input)
@@ -350,8 +350,8 @@ func TestBackpressure(t *testing.T) {
// one batch of dispatches is sent
for range batchSize {
call := testutil.RequireRecvCtx(ctx, t, handler.calls)
testutil.RequireSendCtx(ctx, t, call.result, dispatchResult{
call := testutil.TryReceive(ctx, t, handler.calls)
testutil.RequireSend(ctx, t, call.result, dispatchResult{
retryable: false,
err: nil,
})
@@ -402,7 +402,7 @@ func TestBackpressure(t *testing.T) {
// The batch completes
w.MustWait(ctx)
require.NoError(t, testutil.RequireRecvCtx(ctx, t, stopErr))
require.NoError(t, testutil.TryReceive(ctx, t, stopErr))
require.EqualValues(t, batchSize, storeInterceptor.sent.Load()+storeInterceptor.failed.Load())
}
@@ -1808,7 +1808,7 @@ func TestCustomNotificationMethod(t *testing.T) {
// THEN: the notification should be received by the custom dispatch method
mgr.Run(ctx)
receivedMsgID := testutil.RequireRecvCtx(ctx, t, received)
receivedMsgID := testutil.TryReceive(ctx, t, received)
require.Equal(t, msgID[0].String(), receivedMsgID.String())
// Ensure no messages received by default method (SMTP):