(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestWaitBuffer_WaitForCond(t *testing.T) { |
| 87 | t.Parallel() |
| 88 | ctx := testutil.Context(t, testutil.WaitShort) |
| 89 | |
| 90 | wb := testutil.NewWaitBuffer() |
| 91 | done := make(chan struct{}) |
| 92 | go func() { |
| 93 | defer close(done) |
| 94 | // Wait until the buffer has at least 10 bytes. |
| 95 | _ = wb.WaitForCond(ctx, func(s string) bool { |
| 96 | return len(s) >= 10 |
| 97 | }) |
| 98 | }() |
| 99 | |
| 100 | _, err := wb.Write([]byte("12345")) |
| 101 | require.NoError(t, err) |
| 102 | _, err = wb.Write([]byte("67890")) |
| 103 | require.NoError(t, err) |
| 104 | |
| 105 | select { |
| 106 | case <-done: |
| 107 | case <-ctx.Done(): |
| 108 | t.Fatal("WaitForCond did not unblock when condition was met") |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func TestWaitBuffer_ConcurrentWrites(t *testing.T) { |
| 113 | t.Parallel() |
nothing calls this directly
no test coverage detected