MCPcopy
hub / github.com/IBM/sarama / testRequestDecode

Function testRequestDecode

request_test.go:641–655  ·  view source on GitHub ↗
(t *testing.T, name string, rb protocolBody, packet []byte)

Source from the content-addressed store, hash-verified

639}
640
641func testRequestDecode(t *testing.T, name string, rb protocolBody, packet []byte) {
642 t.Helper()
643 decoded, n, err := decodeRequest(bytes.NewReader(packet))
644 if err != nil {
645 t.Error("Failed to decode request", err)
646 } else if decoded.correlationID != 123 || decoded.clientID != "foo" {
647 t.Errorf("Decoded header %q is not valid: %+v", name, decoded)
648 } else if !reflect.DeepEqual(rb, decoded.body) {
649 t.Error(spew.Sprintf("Decoded request %q does not match the encoded one\nencoded: %+v\ndecoded: %+v", name, rb, decoded.body))
650 } else if n != len(packet) {
651 t.Errorf("Decoded request %q bytes: %d does not match the encoded one: %d\n", name, n, len(packet))
652 } else if rb.version() != decoded.body.version() {
653 t.Errorf("Decoded request %q version: %d does not match the encoded one: %d\n", name, decoded.body.version(), rb.version())
654 }
655}
656
657func testResponse(t *testing.T, name string, res protocolBody, expected []byte) {
658 t.Helper()

Calls 5

decodeRequestFunction · 0.85
HelperMethod · 0.80
ErrorMethod · 0.65
ErrorfMethod · 0.65
versionMethod · 0.65

Tested by

no test coverage detected