(t *testing.T)
| 167 | } |
| 168 | |
| 169 | func 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 | |
| 194 | func TestWaitBuffer_WaitForNth_AlreadySatisfied(t *testing.T) { |
| 195 | t.Parallel() |
nothing calls this directly
no test coverage detected