sync_group_response_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package sarama
  2. import (
  3. "reflect"
  4. "testing"
  5. )
  6. var (
  7. syncGroupResponseNoError = []byte{
  8. 0x00, 0x00, // No error
  9. 0, 0, 0, 3, 0x01, 0x02, 0x03, // Member assignment data
  10. }
  11. syncGroupResponseWithError = []byte{
  12. 0, 27, // ErrRebalanceInProgress
  13. 0, 0, 0, 0, // No member assignment data
  14. }
  15. )
  16. func TestSyncGroupResponse(t *testing.T) {
  17. var response *SyncGroupResponse
  18. response = new(SyncGroupResponse)
  19. testVersionDecodable(t, "no error", response, syncGroupResponseNoError, 0)
  20. if response.Err != ErrNoError {
  21. t.Error("Decoding Err failed: no error expected but found", response.Err)
  22. }
  23. if !reflect.DeepEqual(response.MemberAssignment, []byte{0x01, 0x02, 0x03}) {
  24. t.Error("Decoding MemberAssignment failed, found:", response.MemberAssignment)
  25. }
  26. response = new(SyncGroupResponse)
  27. testVersionDecodable(t, "no error", response, syncGroupResponseWithError, 0)
  28. if response.Err != ErrRebalanceInProgress {
  29. t.Error("Decoding Err failed: ErrRebalanceInProgress expected but found", response.Err)
  30. }
  31. if !reflect.DeepEqual(response.MemberAssignment, []byte{}) {
  32. t.Error("Decoding MemberAssignment failed, found:", response.MemberAssignment)
  33. }
  34. }