Skip to content

Commit

Permalink
Merge pull request #1053 from Shopify/validate-required-version
Browse files Browse the repository at this point in the history
Simple validation of required version
  • Loading branch information
eapache authored Feb 14, 2018
2 parents 2d0f462 + f4fbc32 commit 1995278
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func testVersionDecodable(t *testing.T, name string, out versionedDecoder, in []
}

func testRequest(t *testing.T, name string, rb protocolBody, expected []byte) {
if !rb.requiredVersion().IsAtLeast(MinVersion) {
t.Errorf("Request %s has invalid required version", name)
}
packet := testRequestEncode(t, name, rb, expected)
testRequestDecode(t, name, rb, packet)
}
Expand All @@ -76,6 +79,8 @@ func testRequestDecode(t *testing.T, name string, rb protocolBody, packet []byte
t.Error(spew.Sprintf("Decoded request %q does not match the encoded one\nencoded: %+v\ndecoded: %+v", name, rb, decoded.body))
} else if n != len(packet) {
t.Errorf("Decoded request %q bytes: %d does not match the encoded one: %d\n", name, n, len(packet))
} else if rb.version() != decoded.body.version() {
t.Errorf("Decoded request %q version: %d does not match the encoded one: %d\n", name, decoded.body.version(), rb.version())
}
}

Expand Down

0 comments on commit 1995278

Please sign in to comment.