init_producer_id_response_test.go 650 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package sarama
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. var (
  7. initProducerIDResponse = []byte{
  8. 0, 0, 0, 100,
  9. 0, 0,
  10. 0, 0, 0, 0, 0, 0, 31, 64, // producerID = 8000
  11. 0, 0, // epoch
  12. }
  13. initProducerIDRequestError = []byte{
  14. 0, 0, 0, 100,
  15. 0, 51,
  16. 255, 255, 255, 255, 255, 255, 255, 255,
  17. 0, 0,
  18. }
  19. )
  20. func TestInitProducerIDResponse(t *testing.T) {
  21. resp := &InitProducerIDResponse{
  22. ThrottleTime: 100 * time.Millisecond,
  23. ProducerID: 8000,
  24. ProducerEpoch: 0,
  25. }
  26. testResponse(t, "", resp, initProducerIDResponse)
  27. resp.Err = ErrConcurrentTransactions
  28. resp.ProducerID = -1
  29. testResponse(t, "with error", resp, initProducerIDRequestError)
  30. }