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

Function TestWaitBuffer_WaitFor_Blocks

testutil/wait_buffer_test.go:15–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestWaitBuffer_WaitFor_Blocks(t *testing.T) {
16 t.Parallel()
17 ctx := testutil.Context(t, testutil.WaitShort)
18
19 wb := testutil.NewWaitBuffer()
20 done := make(chan struct{})
21 go func() {
22 defer close(done)
23 _ = wb.WaitFor(ctx, "hello")
24 }()
25
26 // Write the signal after the goroutine is blocking.
27 _, err := wb.Write([]byte("hello"))
28 require.NoError(t, err)
29
30 select {
31 case <-done:
32 case <-ctx.Done():
33 t.Fatal("WaitFor did not unblock after signal was written")
34 }
35}
36
37func TestWaitBuffer_WaitFor_AlreadyPresent(t *testing.T) {
38 t.Parallel()

Callers

nothing calls this directly

Calls 6

WaitForMethod · 0.95
WriteMethod · 0.95
ContextFunction · 0.92
NewWaitBufferFunction · 0.92
FatalMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected