chore: update testutil chan helpers (#17408)

This commit is contained in:
ケイラ
2025-04-16 09:37:09 -07:00
committed by GitHub
parent 2a76f5028e
commit f670bc31f5
45 changed files with 582 additions and 559 deletions

View File

@ -98,7 +98,7 @@ func TestCloserStack_Empty(t *testing.T) {
defer close(closed)
uut.close(nil)
}()
testutil.RequireRecvCtx(ctx, t, closed)
testutil.TryReceive(ctx, t, closed)
}
func TestCloserStack_Context(t *testing.T) {
@ -157,7 +157,7 @@ func TestCloserStack_CloseAfterContext(t *testing.T) {
err := uut.push("async", ac)
require.NoError(t, err)
cancel()
testutil.RequireRecvCtx(testCtx, t, ac.started)
testutil.TryReceive(testCtx, t, ac.started)
closed := make(chan struct{})
go func() {
@ -174,7 +174,7 @@ func TestCloserStack_CloseAfterContext(t *testing.T) {
}
ac.complete()
testutil.RequireRecvCtx(testCtx, t, closed)
testutil.TryReceive(testCtx, t, closed)
}
func TestCloserStack_Timeout(t *testing.T) {
@ -204,20 +204,20 @@ func TestCloserStack_Timeout(t *testing.T) {
}()
trap.MustWait(ctx).Release()
// top starts right away, but it hangs
testutil.RequireRecvCtx(ctx, t, ac[2].started)
testutil.TryReceive(ctx, t, ac[2].started)
// timer pops and we start the middle one
mClock.Advance(gracefulShutdownTimeout).MustWait(ctx)
testutil.RequireRecvCtx(ctx, t, ac[1].started)
testutil.TryReceive(ctx, t, ac[1].started)
// middle one finishes
ac[1].complete()
// bottom starts, but also hangs
testutil.RequireRecvCtx(ctx, t, ac[0].started)
testutil.TryReceive(ctx, t, ac[0].started)
// timer has to pop twice to time out.
mClock.Advance(gracefulShutdownTimeout).MustWait(ctx)
mClock.Advance(gracefulShutdownTimeout).MustWait(ctx)
testutil.RequireRecvCtx(ctx, t, closed)
testutil.TryReceive(ctx, t, closed)
}
type fakeCloser struct {