(t *testing.T, version int16, msg protocol.Message)
| 12 | ) |
| 13 | |
| 14 | func 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. |
no test coverage detected