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

Function TestWaitBuffer_WaitFor_MultipleWrites

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

Source from the content-addressed store, hash-verified

58}
59
60func TestWaitBuffer_WaitFor_MultipleWrites(t *testing.T) {
61 t.Parallel()
62 ctx := testutil.Context(t, testutil.WaitShort)
63
64 wb := testutil.NewWaitBuffer()
65 // Write partial content that doesn't satisfy the condition.
66 _, err := wb.Write([]byte("hell"))
67 require.NoError(t, err)
68
69 done := make(chan struct{})
70 go func() {
71 defer close(done)
72 _ = wb.WaitFor(ctx, "hello")
73 }()
74
75 // Complete the signal with a second write.
76 _, err = wb.Write([]byte("o"))
77 require.NoError(t, err)
78
79 select {
80 case <-done:
81 case <-ctx.Done():
82 t.Fatal("WaitFor did not unblock after multiple writes completed the signal")
83 }
84}
85
86func TestWaitBuffer_WaitForCond(t *testing.T) {
87 t.Parallel()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected