describe_configs_response_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package sarama
  2. import (
  3. "testing"
  4. )
  5. var (
  6. describeConfigsResponseEmpty = []byte{
  7. 0, 0, 0, 0, //throttle
  8. 0, 0, 0, 0, // no configs
  9. }
  10. describeConfigsResponsePopulated = []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. 0, 0, 0, 1, //configs
  18. 0, 10, 's', 'e', 'g', 'm', 'e', 'n', 't', '.', 'm', 's',
  19. 0, 4, '1', '0', '0', '0',
  20. 0, // ReadOnly
  21. 0, // Default
  22. 0, // Sensitive
  23. }
  24. )
  25. func TestDescribeConfigsResponse(t *testing.T) {
  26. var response *DescribeConfigsResponse
  27. response = &DescribeConfigsResponse{
  28. Resources: []*ResourceResponse{},
  29. }
  30. testVersionDecodable(t, "empty", response, describeConfigsResponseEmpty, 0)
  31. if len(response.Resources) != 0 {
  32. t.Error("Expected no groups")
  33. }
  34. response = &DescribeConfigsResponse{
  35. Resources: []*ResourceResponse{
  36. &ResourceResponse{
  37. ErrorCode: 0,
  38. ErrorMsg: "",
  39. Type: TopicResource,
  40. Name: "foo",
  41. Configs: []*ConfigEntry{
  42. &ConfigEntry{
  43. Name: "segment.ms",
  44. Value: "1000",
  45. ReadOnly: false,
  46. Default: false,
  47. Sensitive: false,
  48. },
  49. },
  50. },
  51. },
  52. }
  53. testResponse(t, "response with error", response, describeConfigsResponsePopulated)
  54. }