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

Function testReaderSetRandomOffset

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

Source from the content-addressed store, hash-verified

155}
156
157func testReaderSetRandomOffset(t *testing.T, ctx context.Context, r *Reader) {
158 const N = 10
159 prepareReader(t, ctx, r, makeTestSequence(N)...)
160
161 for i := 0; i != 2*N; i++ {
162 offset := rand.Intn(N)
163 r.SetOffset(int64(offset))
164 m, err := r.ReadMessage(ctx)
165 if err != nil {
166 t.Error("seeking to offset", offset, "failed:", err)
167 return
168 }
169 v, _ := strconv.Atoi(string(m.Value))
170 if v != offset {
171 t.Error("message at offset", offset, "has wrong value:", v)
172 return
173 }
174 }
175}
176
177func testReaderSetOffsetAt(t *testing.T, ctx context.Context, r *Reader) {
178 // We make 2 batches of messages here with a brief 2 second pause

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…