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

Function TestResponse

protocol/prototest/response.go:14–42  ·  protocol/prototest/response.go::TestResponse
(t *testing.T, version int16, msg protocol.Message)

Source from the content-addressed store, hash-verified

12)
13
14func TestResponse(t *testing.T, version int16, msg protocol.Message) {
15 reset := load(msg)
16
17 t.Run(fmt.Sprintf("v%d", version), func(t *testing.T) {
18 b := &bytes.Buffer{}
19
20 if err := protocol.WriteResponse(b, version, 1234, msg); err != nil {
21 t.Fatal(err)
22 }
23
24 reset()
25
26 t.Logf("\n%s", hex.Dump(b.Bytes()))
27
28 correlationID, res, err := protocol.ReadResponse(b, msg.ApiKey(), version)
29 if err != nil {
30 t.Fatal(err)
31 }
32 if correlationID != 1234 {
33 t.Errorf("correlation id mismatch: %d != %d", correlationID, 1234)
34 }
35 if !deepEqual(msg, res) {
36 t.Errorf("response message mismatch:")
37 t.Logf("expected: %+v", msg)
38 t.Logf("found: %+v", res)
39 }
40 closeMessage(res)
41 })
42}
43
44func BenchmarkResponse(b *testing.B, version int16, msg protocol.Message) {
45 reset := load(msg)

Callers 15

TestFetchResponseFunction · 0.92
TestDeleteTopicsResponseFunction · 0.92
TestCreateACLsResponseFunction · 0.92
TestApiversionsResponseFunction · 0.92
TestListOffsetsResponseFunction · 0.92
TestEndTxnResponseFunction · 0.92
TestOffsetCommitResponseFunction · 0.92
TestElectLeadersResponseFunction · 0.92
TestProduceResponseFunction · 0.92
TestAlterConfigsResponseFunction · 0.92

Calls 7

WriteResponseFunction · 0.92
ReadResponseFunction · 0.92
loadFunction · 0.85
deepEqualFunction · 0.85
closeMessageFunction · 0.85
BytesMethod · 0.65
ApiKeyMethod · 0.65

Tested by

no test coverage detected