consumer_metadata_response_test.go 859 B

1234567891011121314151617181920212223242526272829303132333435
  1. package sarama
  2. import "testing"
  3. var (
  4. consumerMetadataResponseError = []byte{
  5. 0x00, 0x0E,
  6. 0x00, 0x00, 0x00, 0x00,
  7. 0x00, 0x00,
  8. 0x00, 0x00, 0x00, 0x00}
  9. consumerMetadataResponseSuccess = []byte{
  10. 0x00, 0x00,
  11. 0x00, 0x00, 0x00, 0xAB,
  12. 0x00, 0x03, 'f', 'o', 'o',
  13. 0x00, 0x00, 0xCC, 0xDD}
  14. )
  15. func TestConsumerMetadataResponseError(t *testing.T) {
  16. response := ConsumerMetadataResponse{Err: ErrOffsetsLoadInProgress}
  17. testResponse(t, "error", &response, consumerMetadataResponseError)
  18. }
  19. func TestConsumerMetadataResponseSuccess(t *testing.T) {
  20. broker := NewBroker("foo:52445")
  21. broker.id = 0xAB
  22. response := ConsumerMetadataResponse{
  23. Coordinator: broker,
  24. CoordinatorID: 0xAB,
  25. CoordinatorHost: "foo",
  26. CoordinatorPort: 0xCCDD,
  27. Err: ErrNoError,
  28. }
  29. testResponse(t, "success", &response, consumerMetadataResponseSuccess)
  30. }