MCPcopy Index your code
hub / github.com/coder/coder / RequireSend

Function RequireSend

testutil/chan.go:52–60  ·  view source on GitHub ↗

RequireSend will send the given value over the chan and then return. If the context expires before the send succeeds, it will fail the test. Safety: Must only be called from the Go routine that created `t`.

(ctx context.Context, t testing.TB, c chan<- A, a A)

Source from the content-addressed store, hash-verified

50//
51// Safety: Must only be called from the Go routine that created `t`.
52func RequireSend[A any](ctx context.Context, t testing.TB, c chan<- A, a A) {
53 t.Helper()
54 select {
55 case <-ctx.Done():
56 require.Fail(t, "RequireSend: context expired")
57 case c <- a:
58 // OK!
59 }
60}
61
62// SoftTryReceive will attempt to receive a value from the chan and return it. If
63// the context expires before a value can be received, it will mark the test as

Callers 15

TestWatchAgentContainersFunction · 0.92
TestBackpressureFunction · 0.92
TestCacheFunction · 0.92
tickMethod · 0.92
TestSpeaker_RawPeerFunction · 0.92
TestTunnel_StartStopFunction · 0.92
TestTunnel_PeerUpdateFunction · 0.92

Calls 3

HelperMethod · 0.65
DoneMethod · 0.45
FailMethod · 0.45

Tested by 15

TestWatchAgentContainersFunction · 0.74
TestBackpressureFunction · 0.74
TestCacheFunction · 0.74
tickMethod · 0.74
TestSpeaker_RawPeerFunction · 0.74
TestTunnel_StartStopFunction · 0.74
TestTunnel_PeerUpdateFunction · 0.74