| 58 | } |
| 59 | |
| 60 | func 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 | |
| 86 | func TestWaitBuffer_WaitForCond(t *testing.T) { |
| 87 | t.Parallel() |