forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alter_partition_reassignments_response_test.go
43 lines (36 loc) · 1.23 KB
/
alter_partition_reassignments_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
package sarama
import "testing"
var (
alterPartitionReassignmentsResponseNoError = []byte{
0, 0, 39, 16, // ThrottleTimeMs 10000
0, 0, // errorcode
0, // null string
1, // empty errors array
0, // empty tagged fields
}
alterPartitionReassignmentsResponseWithError = []byte{
0, 0, 39, 16, // ThrottleTimeMs 10000
0, 12, // errorcode
6, 101, 114, 114, 111, 114, // error string "error"
2, // errors array length 1
6, 116, 111, 112, 105, 99, // topic name "topic"
2, // partition array length 1
0, 0, 0, 1, // partitionId
0, 3, // kerror
7, 101, 114, 114, 111, 114, 50, // error string "error2"
0, 0, 0, // empty tagged fields
}
)
func TestAlterPartitionReassignmentResponse(t *testing.T) {
var response *AlterPartitionReassignmentsResponse = &AlterPartitionReassignmentsResponse{
ThrottleTimeMs: int32(10000),
Version: int16(0),
}
testResponse(t, "no error", response, alterPartitionReassignmentsResponseNoError)
errorMessage := "error"
partitionError := "error2"
response.ErrorCode = 12
response.ErrorMessage = &errorMessage
response.AddError("topic", 1, 3, &partitionError)
testResponse(t, "with error", response, alterPartitionReassignmentsResponseWithError)
}