response_header_test.go 959 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package sarama
  2. import "testing"
  3. var (
  4. responseHeaderBytesV0 = []byte{
  5. 0x00, 0x00, 0x0f, 0x00,
  6. 0x0a, 0xbb, 0xcc, 0xff}
  7. responseHeaderBytesV1 = []byte{
  8. 0x00, 0x00, 0x0f, 0x00,
  9. 0x0a, 0xbb, 0xcc, 0xff, 0x00}
  10. )
  11. func TestResponseHeaderV0(t *testing.T) {
  12. header := responseHeader{}
  13. testVersionDecodable(t, "response header", &header, responseHeaderBytesV0, 0)
  14. if header.length != 0xf00 {
  15. t.Error("Decoding header length failed, got", header.length)
  16. }
  17. if header.correlationID != 0x0abbccff {
  18. t.Error("Decoding header correlation id failed, got", header.correlationID)
  19. }
  20. }
  21. func TestResponseHeaderV1(t *testing.T) {
  22. header := responseHeader{}
  23. testVersionDecodable(t, "response header", &header, responseHeaderBytesV1, 1)
  24. if header.length != 0xf00 {
  25. t.Error("Decoding header length failed, got", header.length)
  26. }
  27. if header.correlationID != 0x0abbccff {
  28. t.Error("Decoding header correlation id failed, got", header.correlationID)
  29. }
  30. }