(t *testing.T, ctx context.Context, r *Reader)
| 252 | } |
| 253 | |
| 254 | func testReaderOutOfRangeGetsCanceled(t *testing.T, ctx context.Context, r *Reader) { |
| 255 | prepareReader(t, ctx, r, makeTestSequence(10)...) |
| 256 | |
| 257 | const D = 100 * time.Millisecond |
| 258 | t0 := time.Now() |
| 259 | |
| 260 | ctx, cancel := context.WithTimeout(ctx, D) |
| 261 | defer cancel() |
| 262 | |
| 263 | if err := r.SetOffset(42); err != nil { |
| 264 | t.Error(err) |
| 265 | } |
| 266 | |
| 267 | _, err := r.ReadMessage(ctx) |
| 268 | if !errors.Is(err, context.DeadlineExceeded) { |
| 269 | t.Error("bad error:", err) |
| 270 | } |
| 271 | |
| 272 | t1 := time.Now() |
| 273 | |
| 274 | if d := t1.Sub(t0); d < D { |
| 275 | t.Error("ReadMessage returned too early after", d) |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | func createTopic(t *testing.T, topic string, partitions int) { |
| 280 | t.Helper() |
nothing calls this directly
no test coverage detected
searching dependent graphs…