init_producer_id_request_test.go 528 B

12345678910111213141516171819202122232425262728293031
  1. package sarama
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. var (
  7. initProducerIDRequestNull = []byte{
  8. 255, 255,
  9. 0, 0, 0, 100,
  10. }
  11. initProducerIDRequest = []byte{
  12. 0, 3, 't', 'x', 'n',
  13. 0, 0, 0, 100,
  14. }
  15. )
  16. func TestInitProducerIDRequest(t *testing.T) {
  17. req := &InitProducerIDRequest{
  18. TransactionTimeout: 100 * time.Millisecond,
  19. }
  20. testRequest(t, "null transaction id", req, initProducerIDRequestNull)
  21. transactionID := "txn"
  22. req.TransactionalID = &transactionID
  23. testRequest(t, "transaction id", req, initProducerIDRequest)
  24. }