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

Function TestWaitBuffer_WaitForNth_Blocks

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

Source from the content-addressed store, hash-verified

167}
168
169func TestWaitBuffer_WaitForNth_Blocks(t *testing.T) {
170 t.Parallel()
171 ctx := testutil.Context(t, testutil.WaitShort)
172
173 wb := testutil.NewWaitBuffer()
174 _, err := wb.Write([]byte("Foo "))
175 require.NoError(t, err)
176
177 // First occurrence is already present, but we want two.
178 done := make(chan struct{})
179 go func() {
180 defer close(done)
181 _ = wb.WaitForNth(ctx, "Foo", 2)
182 }()
183
184 _, err = wb.Write([]byte("Bar Foo"))
185 require.NoError(t, err)
186
187 select {
188 case <-done:
189 case <-ctx.Done():
190 t.Fatal("WaitForNth did not unblock after second occurrence")
191 }
192}
193
194func TestWaitBuffer_WaitForNth_AlreadySatisfied(t *testing.T) {
195 t.Parallel()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected