test(busretry): stop attempts from blocking on a full channel after cancel
- commit
- e6d2caf1de9cb0c1866d7244eac06f071d725e57
- author
- brice · · 2026-10-08 19:54 UTC
- parent
- 412bdb0
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +4 -1
M internal/adapters/busretry/busretry_test.go +4 -1
| @@ -20,7 +20,10 @@ func TestRunRetriesUntilCancelled(t *testing.T) { | |||
| 20 | 20 | defer close(done) | |
| 21 | 21 | Run(ctx, time.Millisecond, "test feature", logging.For(ctx, "test"), func(context.Context) error { | |
| 22 | 22 | n++ | |
| 23 | - | calls <- n | |
| 23 | + | select { | |
| 24 | + | case calls <- n: | |
| 25 | + | case <-ctx.Done(): | |
| 26 | + | } | |
| 24 | 27 | if n%2 == 0 { | |
| 25 | 28 | return nil | |
| 26 | 29 | } | |
| @@ -20,7 +20,10 @@ func TestRunRetriesUntilCancelled(t *testing.T) { | |||||
| 20 | defer close(done) | 20 | defer close(done) | ||
| 21 | Run(ctx, time.Millisecond, "test feature", logging.For(ctx, "test"), func(context.Context) error { | 21 | Run(ctx, time.Millisecond, "test feature", logging.For(ctx, "test"), func(context.Context) error { | ||
| 22 | n++ | 22 | n++ | ||
| 23 | - | calls <- n | 23 | + | select { |
| 24 | + | case calls <- n: | |||
| 25 | + | case <-ctx.Done(): | |||
| 26 | + | } | |||
| 24 | if n%2 == 0 { | 27 | if n%2 == 0 { | ||
| 25 | return nil | 28 | return nil | ||
| 26 | } | 29 | } | ||