join_group_request_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package sarama
  2. import "testing"
  3. var (
  4. joinGroupRequestNoProtocols = []byte{
  5. 0, 9, 'T', 'e', 's', 't', 'G', 'r', 'o', 'u', 'p', // Group ID
  6. 0, 0, 0, 100, // Session timeout
  7. 0, 0, // Member ID
  8. 0, 8, 'c', 'o', 'n', 's', 'u', 'm', 'e', 'r', // Protocol Type
  9. 0, 0, 0, 0, // 0 protocol groups
  10. }
  11. joinGroupRequestOneProtocol = []byte{
  12. 0, 9, 'T', 'e', 's', 't', 'G', 'r', 'o', 'u', 'p', // Group ID
  13. 0, 0, 0, 100, // Session timeout
  14. 0, 11, 'O', 'n', 'e', 'P', 'r', 'o', 't', 'o', 'c', 'o', 'l', // Member ID
  15. 0, 8, 'c', 'o', 'n', 's', 'u', 'm', 'e', 'r', // Protocol Type
  16. 0, 0, 0, 1, // 1 group protocol
  17. 0, 3, 'o', 'n', 'e', // Protocol name
  18. 0, 0, 0, 3, 0x01, 0x02, 0x03, // protocol metadata
  19. }
  20. )
  21. func TestJoinGroupRequest(t *testing.T) {
  22. var request *JoinGroupRequest
  23. request = new(JoinGroupRequest)
  24. request.GroupId = "TestGroup"
  25. request.SessionTimeout = 100
  26. request.ProtocolType = "consumer"
  27. testRequest(t, "no protocols", request, joinGroupRequestNoProtocols)
  28. request = new(JoinGroupRequest)
  29. request.GroupId = "TestGroup"
  30. request.SessionTimeout = 100
  31. request.MemberId = "OneProtocol"
  32. request.ProtocolType = "consumer"
  33. request.AddGroupProtocol("one", []byte{0x01, 0x02, 0x03})
  34. testRequest(t, "one protocol", request, joinGroupRequestOneProtocol)
  35. }