describe_groups_request_test.go 833 B

12345678910111213141516171819202122232425262728293031323334
  1. package sarama
  2. import "testing"
  3. var (
  4. emptyDescribeGroupsRequest = []byte{0, 0, 0, 0}
  5. singleDescribeGroupsRequest = []byte{
  6. 0, 0, 0, 1, // 1 group
  7. 0, 3, 'f', 'o', 'o', // group name: foo
  8. }
  9. doubleDescribeGroupsRequest = []byte{
  10. 0, 0, 0, 2, // 2 groups
  11. 0, 3, 'f', 'o', 'o', // group name: foo
  12. 0, 3, 'b', 'a', 'r', // group name: foo
  13. }
  14. )
  15. func TestDescribeGroupsRequest(t *testing.T) {
  16. var request *DescribeGroupsRequest
  17. request = new(DescribeGroupsRequest)
  18. testRequest(t, "no groups", request, emptyDescribeGroupsRequest)
  19. request = new(DescribeGroupsRequest)
  20. request.AddGroup("foo")
  21. testRequest(t, "one group", request, singleDescribeGroupsRequest)
  22. request = new(DescribeGroupsRequest)
  23. request.AddGroup("foo")
  24. request.AddGroup("bar")
  25. testRequest(t, "two groups", request, doubleDescribeGroupsRequest)
  26. }