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:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user