delete_groups_response_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package sarama
  2. import (
  3. "testing"
  4. )
  5. var (
  6. emptyDeleteGroupsResponse = []byte{
  7. 0, 0, 0, 0, // does not violate any quota
  8. 0, 0, 0, 0, // no groups
  9. }
  10. errorDeleteGroupsResponse = []byte{
  11. 0, 0, 0, 0, // does not violate any quota
  12. 0, 0, 0, 1, // 1 group
  13. 0, 3, 'f', 'o', 'o', // group name
  14. 0, 31, // error ErrClusterAuthorizationFailed
  15. }
  16. noErrorDeleteGroupsResponse = []byte{
  17. 0, 0, 0, 0, // does not violate any quota
  18. 0, 0, 0, 1, // 1 group
  19. 0, 3, 'f', 'o', 'o', // group name
  20. 0, 0, // no error
  21. }
  22. )
  23. func TestDeleteGroupsResponse(t *testing.T) {
  24. var response *DeleteGroupsResponse
  25. response = new(DeleteGroupsResponse)
  26. testVersionDecodable(t, "empty", response, emptyDeleteGroupsResponse, 0)
  27. if response.ThrottleTime != 0 {
  28. t.Error("Expected no violation")
  29. }
  30. if len(response.GroupErrorCodes) != 0 {
  31. t.Error("Expected no groups")
  32. }
  33. response = new(DeleteGroupsResponse)
  34. testVersionDecodable(t, "error", response, errorDeleteGroupsResponse, 0)
  35. if response.ThrottleTime != 0 {
  36. t.Error("Expected no violation")
  37. }
  38. if response.GroupErrorCodes["foo"] != ErrClusterAuthorizationFailed {
  39. t.Error("Expected error ErrClusterAuthorizationFailed, found:", response.GroupErrorCodes["foo"])
  40. }
  41. response = new(DeleteGroupsResponse)
  42. testVersionDecodable(t, "no error", response, noErrorDeleteGroupsResponse, 0)
  43. if response.ThrottleTime != 0 {
  44. t.Error("Expected no violation")
  45. }
  46. if response.GroupErrorCodes["foo"] != ErrNoError {
  47. t.Error("Expected error ErrClusterAuthorizationFailed, found:", response.GroupErrorCodes["foo"])
  48. }
  49. }