forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_versions_response_test.go
59 lines (54 loc) · 1.74 KB
/
api_versions_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
package sarama
import "testing"
var (
apiVersionResponse = []byte{
0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x00, 0x03,
0x00, 0x02,
0x00, 0x01,
}
apiVersionResponseV3 = []byte{
0x00, 0x00, // no error
0x02, // compact array length 1
0x00, 0x03,
0x00, 0x02,
0x00, 0x01,
0x00, // tagged fields
0x00, 0x00, 0x00, 0x00, // throttle time
0x00, // tagged fields
}
)
func TestApiVersionsResponse(t *testing.T) {
response := new(ApiVersionsResponse)
testVersionDecodable(t, "no error", response, apiVersionResponse, 0)
if response.ErrorCode != int16(ErrNoError) {
t.Error("Decoding error failed: no error expected but found", response.ErrorCode)
}
if response.ApiKeys[0].ApiKey != 0x03 {
t.Error("Decoding error: expected 0x03 but got", response.ApiKeys[0].ApiKey)
}
if response.ApiKeys[0].MinVersion != 0x02 {
t.Error("Decoding error: expected 0x02 but got", response.ApiKeys[0].MinVersion)
}
if response.ApiKeys[0].MaxVersion != 0x01 {
t.Error("Decoding error: expected 0x01 but got", response.ApiKeys[0].MaxVersion)
}
}
func TestApiVersionsResponseV3(t *testing.T) {
response := new(ApiVersionsResponse)
response.Version = 3
testVersionDecodable(t, "no error", response, apiVersionResponseV3, 3)
if response.ErrorCode != int16(ErrNoError) {
t.Error("Decoding error failed: no error expected but found", response.ErrorCode)
}
if response.ApiKeys[0].ApiKey != 0x03 {
t.Error("Decoding error: expected 0x03 but got", response.ApiKeys[0].ApiKey)
}
if response.ApiKeys[0].MinVersion != 0x02 {
t.Error("Decoding error: expected 0x02 but got", response.ApiKeys[0].MinVersion)
}
if response.ApiKeys[0].MaxVersion != 0x01 {
t.Error("Decoding error: expected 0x01 but got", response.ApiKeys[0].MaxVersion)
}
}