forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_offsets_response_test.go
75 lines (66 loc) · 1.63 KB
/
delete_offsets_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package sarama
import (
"testing"
)
var (
emptyDeleteOffsetsResponse = []byte{
0, 0, // no error
0, 0, 0, 0, // 0 throttle
0, 0, 0, 0, // 0 topics
}
errorDeleteOffsetsResponse = []byte{
0, 16, // error 16 : ErrNotCoordinatorForConsumer
0, 0, 0, 0, // 0 throttle
0, 0, 0, 1, // 1 topic
0, 3, 'b', 'a', 'r', // topic name: bar
0, 0, 0, 1, // 1 partition
0, 0, 0, 6, // partition 6
0, 0, // no error
}
errorOnPartitionResponse = []byte{
0, 0, // no error
0, 0, 0, 0, // 0 throttle
0, 0, 0, 1, // 1 topic
0, 3, 'b', 'a', 'r', // topic name: bar
0, 0, 0, 1, // 1 partition
0, 0, 0, 6, // partition 6
0, 86, // error ErrGroupSubscribedToTopic=86
}
)
func TestDeleteOffsetsResponse(t *testing.T) {
var response *DeleteOffsetsResponse
response = &DeleteOffsetsResponse{
ErrorCode: 0,
ThrottleTime: 0,
}
testResponse(t, "empty no error", response, emptyDeleteOffsetsResponse)
response = &DeleteOffsetsResponse{
ErrorCode: 0,
ThrottleTime: 0,
Errors: map[string]map[int32]KError{
"bar": {
6: 0,
7: 0,
},
},
}
// The response encoded form cannot be checked for it varies due to
// unpredictable map traversal order.
testResponse(t, "no error", response, nil)
response = &DeleteOffsetsResponse{
ErrorCode: 16,
ThrottleTime: 0,
Errors: map[string]map[int32]KError{
"bar": {
6: 0,
},
},
}
testResponse(t, "error global", response, errorDeleteOffsetsResponse)
response = &DeleteOffsetsResponse{
ErrorCode: 0,
ThrottleTime: 0,
}
response.AddError("bar", 6, ErrGroupSubscribedToTopic)
testResponse(t, "error partition", response, errorOnPartitionResponse)
}