api_versions_response_test.go 871 B

1234567891011121314151617181920212223242526272829303132
  1. package sarama
  2. import "testing"
  3. var (
  4. apiVersionResponse = []byte{
  5. 0x00, 0x00,
  6. 0x00, 0x00, 0x00, 0x01,
  7. 0x00, 0x03,
  8. 0x00, 0x02,
  9. 0x00, 0x01,
  10. }
  11. )
  12. func TestApiVersionsResponse(t *testing.T) {
  13. var response *ApiVersionsResponse
  14. response = new(ApiVersionsResponse)
  15. testVersionDecodable(t, "no error", response, apiVersionResponse, 0)
  16. if response.Err != ErrNoError {
  17. t.Error("Decoding error failed: no error expected but found", response.Err)
  18. }
  19. if response.ApiVersions[0].ApiKey != 0x03 {
  20. t.Error("Decoding error: expected 0x03 but got", response.ApiVersions[0].ApiKey)
  21. }
  22. if response.ApiVersions[0].MinVersion != 0x02 {
  23. t.Error("Decoding error: expected 0x02 but got", response.ApiVersions[0].MinVersion)
  24. }
  25. if response.ApiVersions[0].MaxVersion != 0x01 {
  26. t.Error("Decoding error: expected 0x01 but got", response.ApiVersions[0].MaxVersion)
  27. }
  28. }