@@ -15,6 +15,8 @@ func Context(t *testing.T, dur time.Duration) context.Context {
15
15
// TryRecvCtx will attempt to receive a value from the chan and return it. If
16
16
// the context expires before a value can be received, it will fail the test. If
17
17
// the channel is closed, the zero value of the channel type will be returned.
18
+ //
19
+ // Safety: Must only be called from the Go routine that created `t`.
18
20
func TryRecvCtx [A any ](ctx context.Context , t testing.TB , c <- chan A ) A {
19
21
t .Helper ()
20
22
select {
@@ -30,6 +32,8 @@ func TryRecvCtx[A any](ctx context.Context, t testing.TB, c <-chan A) A {
30
32
// RequireRecvCtx will receive a value from the chan and return it. If the
31
33
// context expires or the channel is closed before a value can be received,
32
34
// it will fail the test.
35
+ //
36
+ // Safety: Must only be called from the Go routine that created `t`.
33
37
func RequireRecvCtx [A any ](ctx context.Context , t testing.TB , c <- chan A ) A {
34
38
t .Helper ()
35
39
select {
@@ -47,6 +51,8 @@ func RequireRecvCtx[A any](ctx context.Context, t testing.TB, c <-chan A) A {
47
51
48
52
// RequireSendCtx will send the given value over the chan and then return. If
49
53
// the context expires before the send succeeds, it will fail the test.
54
+ //
55
+ // Safety: Must only be called from the Go routine that created `t`.
50
56
func RequireSendCtx [A any ](ctx context.Context , t testing.TB , c chan <- A , a A ) {
51
57
t .Helper ()
52
58
select {
0 commit comments