MCPcopy
hub / github.com/segmentio/kafka-go / testReaderOutOfRangeGetsCanceled

Function testReaderOutOfRangeGetsCanceled

reader_test.go:254–277  ·  view source on GitHub ↗
(t *testing.T, ctx context.Context, r *Reader)

Source from the content-addressed store, hash-verified

252}
253
254func 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
279func createTopic(t *testing.T, topic string, partitions int) {
280 t.Helper()

Callers

nothing calls this directly

Calls 5

prepareReaderFunction · 0.85
makeTestSequenceFunction · 0.85
SetOffsetMethod · 0.80
ErrorMethod · 0.45
ReadMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…