AssertSend will send the given value over the chan and then return. If the context expires before the send succeeds, it will mark the test as failed but continue execution. The second return value indicates whether the send was successful. Safety: can be called from any goroutine.
(ctx context.Context, t testing.TB, c chan<- A, a A)
| 107 | // |
| 108 | // Safety: can be called from any goroutine. |
| 109 | func AssertSend[A any](ctx context.Context, t testing.TB, c chan<- A, a A) bool { |
| 110 | t.Helper() |
| 111 | select { |
| 112 | case <-ctx.Done(): |
| 113 | assert.Fail(t, "AssertSend: context expired") |
| 114 | return false |
| 115 | case c <- a: |
| 116 | return true |
| 117 | } |
| 118 | } |