forked from davidgev/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoffset_commit_response_test.go
52 lines (37 loc) · 1.13 KB
/
offset_commit_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
41
42
43
44
45
46
47
48
49
50
51
52
package sarama
import "testing"
var (
emptyOffsetCommitResponse = []byte{
0x00, 0x00, 0x00, 0x00}
normalOffsetCommitResponse = []byte{
0x00, 0x00, 0x00, 0x02,
0x00, 0x01, 'm',
0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 't',
0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00,
0x00, 0x06}
)
func TestEmptyOffsetCommitResponse(t *testing.T) {
response := OffsetCommitResponse{}
testDecodable(t, "empty", &response, emptyOffsetCommitResponse)
if len(response.Errors) != 0 {
t.Error("Decoding produced errors where there were none.")
}
}
func TestNormalOffsetCommitResponse(t *testing.T) {
response := OffsetCommitResponse{}
testDecodable(t, "normal", &response, normalOffsetCommitResponse)
if len(response.Errors) != 2 {
t.Fatal("Decoding produced wrong number of errors.")
}
if len(response.Errors["m"]) != 0 {
t.Error("Decoding produced errors for topic 'm' where there were none.")
}
if len(response.Errors["t"]) != 1 {
t.Fatal("Decoding produced wrong number of errors for topic 't'.")
}
if response.Errors["t"][0] != NotLeaderForPartition {
t.Error("Decoding produced wrong error for topic 't' partition 0.")
}
}