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

Function TestFetchResponse

protocol/fetch/fetch_test.go:37–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestFetchResponse(t *testing.T) {
38 t0 := time.Now().Truncate(time.Millisecond)
39 t1 := t0.Add(1 * time.Millisecond)
40 t2 := t0.Add(2 * time.Millisecond)
41
42 prototest.TestResponse(t, v0, &fetch.Response{
43 Topics: []fetch.ResponseTopic{
44 {
45 Topic: "topic-1",
46 Partitions: []fetch.ResponsePartition{
47 {
48 Partition: 1,
49 HighWatermark: 1000,
50 RecordSet: protocol.RecordSet{
51 Version: 1,
52 Records: protocol.NewRecordReader(
53 protocol.Record{Offset: 0, Time: t0, Key: nil, Value: prototest.String("msg-0")},
54 protocol.Record{Offset: 1, Time: t1, Key: nil, Value: prototest.String("msg-1")},
55 protocol.Record{Offset: 2, Time: t2, Key: prototest.Bytes([]byte{1}), Value: prototest.String("msg-2")},
56 ),
57 },
58 },
59 },
60 },
61 },
62 })
63
64 headers := []protocol.Header{
65 {Key: "key-1", Value: []byte("value-1")},
66 {Key: "key-2", Value: []byte("value-2")},
67 {Key: "key-3", Value: []byte("value-3")},
68 }
69
70 prototest.TestResponse(t, v11, &fetch.Response{
71 Topics: []fetch.ResponseTopic{
72 {
73 Topic: "topic-1",
74 Partitions: []fetch.ResponsePartition{
75 {
76 Partition: 1,
77 HighWatermark: 1000,
78 RecordSet: protocol.RecordSet{
79 Version: 2,
80 Records: protocol.NewRecordReader(
81 protocol.Record{Offset: 0, Time: t0, Key: nil, Value: prototest.String("msg-0"), Headers: headers},
82 protocol.Record{Offset: 1, Time: t1, Key: nil, Value: prototest.String("msg-1")},
83 protocol.Record{Offset: 2, Time: t2, Key: prototest.Bytes([]byte{1}), Value: prototest.String("msg-2")},
84 ),
85 },
86 },
87 },
88 },
89 },
90 })
91}
92
93func BenchmarkFetchResponse(b *testing.B) {
94 t0 := time.Now().Truncate(time.Millisecond)

Callers

nothing calls this directly

Calls 5

TestResponseFunction · 0.92
NewRecordReaderFunction · 0.92
StringFunction · 0.92
BytesFunction · 0.92
TruncateMethod · 0.45

Tested by

no test coverage detected