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

Function TestReader

reader_test.go:21–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestReader(t *testing.T) {
22 tests := []struct {
23 scenario string
24 function func(*testing.T, context.Context, *Reader)
25 }{
26 {
27 scenario: "calling Read with a context that has been canceled returns an error",
28 function: testReaderReadCanceled,
29 },
30
31 {
32 scenario: "all messages of the stream are returned when calling ReadMessage repeatedly",
33 function: testReaderReadMessages,
34 },
35
36 {
37 scenario: "test special offsets -1 and -2",
38 function: testReaderSetSpecialOffsets,
39 },
40
41 {
42 scenario: "setting the offset to random values returns the expected messages when Read is called",
43 function: testReaderSetRandomOffset,
44 },
45
46 {
47 scenario: "setting the offset by TimeStamp",
48 function: testReaderSetOffsetAt,
49 },
50
51 {
52 scenario: "calling Lag returns the lag of the last message read from kafka",
53 function: testReaderLag,
54 },
55
56 {
57 scenario: "calling ReadLag returns the current lag of a reader",
58 function: testReaderReadLag,
59 },
60
61 { // https://github.com/segmentio/kafka-go/issues/30
62 scenario: "reading from an out-of-range offset waits until the context is cancelled",
63 function: testReaderOutOfRangeGetsCanceled,
64 },
65
66 {
67 scenario: "topic being recreated will return an error",
68 function: testReaderTopicRecreated,
69 },
70 }
71
72 for _, test := range tests {
73 testFunc := test.function
74 t.Run(test.scenario, func(t *testing.T) {
75 t.Parallel()
76
77 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
78 defer cancel()

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
NewReaderFunction · 0.85
newTestKafkaLoggerFunction · 0.85
makeTopicFunction · 0.70

Tested by

no test coverage detected