forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_group_response_test.go
40 lines (34 loc) · 1.14 KB
/
sync_group_response_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package sarama
import (
"reflect"
"testing"
)
var (
syncGroupResponseNoError = []byte{
0x00, 0x00, // No error
0, 0, 0, 3, 0x01, 0x02, 0x03, // Member assignment data
}
syncGroupResponseWithError = []byte{
0, 27, // ErrRebalanceInProgress
0, 0, 0, 0, // No member assignment data
}
)
func TestSyncGroupResponse(t *testing.T) {
var response *SyncGroupResponse
response = new(SyncGroupResponse)
testVersionDecodable(t, "no error", response, syncGroupResponseNoError, 0)
if response.Err != ErrNoError {
t.Error("Decoding Err failed: no error expected but found", response.Err)
}
if !reflect.DeepEqual(response.MemberAssignment, []byte{0x01, 0x02, 0x03}) {
t.Error("Decoding MemberAssignment failed, found:", response.MemberAssignment)
}
response = new(SyncGroupResponse)
testVersionDecodable(t, "no error", response, syncGroupResponseWithError, 0)
if response.Err != ErrRebalanceInProgress {
t.Error("Decoding Err failed: ErrRebalanceInProgress expected but found", response.Err)
}
if !reflect.DeepEqual(response.MemberAssignment, []byte{}) {
t.Error("Decoding MemberAssignment failed, found:", response.MemberAssignment)
}
}