api_versions_response_test.go 836 B

123456789101112131415161718192021222324252627282930
  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. response := new(ApiVersionsResponse)
  14. testVersionDecodable(t, "no error", response, apiVersionResponse, 0)
  15. if response.Err != ErrNoError {
  16. t.Error("Decoding error failed: no error expected but found", response.Err)
  17. }
  18. if response.ApiVersions[0].ApiKey != 0x03 {
  19. t.Error("Decoding error: expected 0x03 but got", response.ApiVersions[0].ApiKey)
  20. }
  21. if response.ApiVersions[0].MinVersion != 0x02 {
  22. t.Error("Decoding error: expected 0x02 but got", response.ApiVersions[0].MinVersion)
  23. }
  24. if response.ApiVersions[0].MaxVersion != 0x01 {
  25. t.Error("Decoding error: expected 0x01 but got", response.ApiVersions[0].MaxVersion)
  26. }
  27. }