10000 oh boy · coder/coder@e8c1b31 · GitHub
[go: up one dir, main page]

Skip to content

Commit e8c1b31

Browse files
committed
oh boy
1 parent 6255c8f commit e8c1b31

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

testutil/ctx.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ func Context(t *testing.T, dur time.Duration) context.Context {
1515
// TryRecvCtx will attempt to receive a value from the chan and return it. If
1616
// the context expires before a value can be received, it will fail the test. If
1717
// 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`.
1820
func TryRecvCtx[A any](ctx context.Context, t testing.TB, c <-chan A) A {
1921
t.Helper()
2022
select {
@@ -30,6 +32,8 @@ func TryRecvCtx[A any](ctx context.Context, t testing.TB, c <-chan A) A {
3032
// RequireRecvCtx will receive a value from the chan and return it. If the
3133
// context expires or the channel is closed before a value can be received,
3234
// it will fail the test.
35+
//
36+
// Safety: Must only be called from the Go routine that created `t`.
3337
func RequireRecvCtx[A any](ctx context.Context, t testing.TB, c <-chan A) A {
3438
t.Helper()
3539
select {
@@ -47,6 +51,8 @@ func RequireRecvCtx[A any](ctx context.Context, t testing.TB, c <-chan A) A {
4751

4852
// RequireSendCtx will send the given value over the chan and then return. If
4953
// 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`.
5056
func RequireSendCtx[A any](ctx context.Context, t testing.TB, c chan<- A, a A) {
5157
t.Helper()
5258
select {

0 commit comments

Comments
 (0)
0