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

Function TestRequest

protocol/prototest/request.go:14–47  ·  view source on GitHub ↗
(t *testing.T, version int16, msg protocol.Message)

Source from the content-addressed store, hash-verified

12)
13
14func TestRequest(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.WriteRequest(b, version, 1234, "me", msg); err != nil {
21 t.Fatal(err)
22 }
23
24 reset()
25
26 t.Logf("\n%s\n", hex.Dump(b.Bytes()))
27
28 apiVersion, correlationID, clientID, req, err := protocol.ReadRequest(b)
29 if err != nil {
30 t.Fatal(err)
31 }
32 if apiVersion != version {
33 t.Errorf("api version mismatch: %d != %d", apiVersion, version)
34 }
35 if correlationID != 1234 {
36 t.Errorf("correlation id mismatch: %d != %d", correlationID, 1234)
37 }
38 if clientID != "me" {
39 t.Errorf("client id mismatch: %q != %q", clientID, "me")
40 }
41 if !deepEqual(msg, req) {
42 t.Errorf("request message mismatch:")
43 t.Logf("expected: %+v", msg)
44 t.Logf("found: %+v", req)
45 }
46 })
47}
48
49// TestRequestWithOverride validates requests that have an overridden type. For requests with type overrides, we
50// double-serialize the request to ensure the resulting encoding of the overridden and original type are identical.

Callers 15

TestFetchRequestFunction · 0.92
TestDeleteTopicsRequestFunction · 0.92
TestCreateACLsRequestFunction · 0.92
TestApiversionsRequestFunction · 0.92
TestListOffsetsRequestFunction · 0.92
TestEndTxnRequestFunction · 0.92
TestOffsetCommitRequestFunction · 0.92
TestElectLeadersRequestFunction · 0.92
TestProduceRequestFunction · 0.92
TestAlterConfigsRequestFunction · 0.92

Calls 5

WriteRequestFunction · 0.92
ReadRequestFunction · 0.92
loadFunction · 0.85
deepEqualFunction · 0.85
BytesMethod · 0.65

Tested by

no test coverage detected