acl_create_response_test.go 761 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package sarama
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. var (
  7. createResponseWithError = []byte{
  8. 0, 0, 0, 100,
  9. 0, 0, 0, 1,
  10. 0, 42,
  11. 0, 5, 'e', 'r', 'r', 'o', 'r',
  12. }
  13. createResponseArray = []byte{
  14. 0, 0, 0, 100,
  15. 0, 0, 0, 2,
  16. 0, 42,
  17. 0, 5, 'e', 'r', 'r', 'o', 'r',
  18. 0, 0,
  19. 255, 255,
  20. }
  21. )
  22. func TestCreateAclsResponse(t *testing.T) {
  23. errmsg := "error"
  24. resp := &CreateAclsResponse{
  25. ThrottleTime: 100 * time.Millisecond,
  26. AclCreationResponses: []*AclCreationResponse{{
  27. Err: ErrInvalidRequest,
  28. ErrMsg: &errmsg,
  29. }},
  30. }
  31. testResponse(t, "response with error", resp, createResponseWithError)
  32. resp.AclCreationResponses = append(resp.AclCreationResponses, new(AclCreationResponse))
  33. testResponse(t, "response array", resp, createResponseArray)
  34. }