alter_configs_response_test.go 898 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package sarama
  2. import (
  3. "testing"
  4. )
  5. var (
  6. alterResponseEmpty = []byte{
  7. 0, 0, 0, 0, //throttle
  8. 0, 0, 0, 0, // no configs
  9. }
  10. alterResponsePopulated = []byte{
  11. 0, 0, 0, 0, //throttle
  12. 0, 0, 0, 1, // response
  13. 0, 0, //errorcode
  14. 0, 0, //string
  15. 2, // topic
  16. 0, 3, 'f', 'o', 'o',
  17. }
  18. )
  19. func TestAlterConfigsResponse(t *testing.T) {
  20. var response *AlterConfigsResponse
  21. response = &AlterConfigsResponse{
  22. Resources: []*AlterConfigsResourceResponse{},
  23. }
  24. testVersionDecodable(t, "empty", response, alterResponseEmpty, 0)
  25. if len(response.Resources) != 0 {
  26. t.Error("Expected no groups")
  27. }
  28. response = &AlterConfigsResponse{
  29. Resources: []*AlterConfigsResourceResponse{
  30. &AlterConfigsResourceResponse{
  31. ErrorCode: 0,
  32. ErrorMsg: "",
  33. Type: TopicResource,
  34. Name: "foo",
  35. },
  36. },
  37. }
  38. testResponse(t, "response with error", response, alterResponsePopulated)
  39. }