sync_group_request_test.go 975 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package sarama
  2. import "testing"
  3. var (
  4. emptySyncGroupRequest = []byte{
  5. 0, 3, 'f', 'o', 'o', // Group ID
  6. 0x00, 0x01, 0x02, 0x03, // Generation ID
  7. 0, 3, 'b', 'a', 'z', // Member ID
  8. 0, 0, 0, 0, // no assignments
  9. }
  10. populatedSyncGroupRequest = []byte{
  11. 0, 3, 'f', 'o', 'o', // Group ID
  12. 0x00, 0x01, 0x02, 0x03, // Generation ID
  13. 0, 3, 'b', 'a', 'z', // Member ID
  14. 0, 0, 0, 1, // one assignment
  15. 0, 3, 'b', 'a', 'z', // Member ID
  16. 0, 0, 0, 3, 'f', 'o', 'o', // Member assignment
  17. }
  18. )
  19. func TestSyncGroupRequest(t *testing.T) {
  20. var request *SyncGroupRequest
  21. request = new(SyncGroupRequest)
  22. request.GroupID = "foo"
  23. request.GenerationID = 66051
  24. request.MemberID = "baz"
  25. testRequest(t, "empty", request, emptySyncGroupRequest)
  26. request = new(SyncGroupRequest)
  27. request.GroupID = "foo"
  28. request.GenerationID = 66051
  29. request.MemberID = "baz"
  30. request.AddGroupAssignment("baz", []byte("foo"))
  31. testRequest(t, "populated", request, populatedSyncGroupRequest)
  32. }