forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
consumer_metadata_response_test.go
61 lines (46 loc) · 1.38 KB
/
consumer_metadata_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
package sarama
import "testing"
var (
consumerMetadataResponseError = []byte{
0x00, 0x0E,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00}
consumerMetadataResponseSuccess = []byte{
0x00, 0x00,
0x00, 0x00, 0x00, 0xAB,
0x00, 0x03, 'f', 'o', 'o',
0x00, 0x00, 0xCC, 0xDD}
)
func TestConsumerMetadataResponseError(t *testing.T) {
response := ConsumerMetadataResponse{}
testDecodable(t, "error", &response, consumerMetadataResponseError)
if response.Err != OffsetsLoadInProgress {
t.Error("Decoding produced incorrect error value.")
}
if response.CoordinatorId != 0 {
t.Error("Decoding produced incorrect ID.")
}
if len(response.CoordinatorHost) != 0 {
t.Error("Decoding produced incorrect host.")
}
if response.CoordinatorPort != 0 {
t.Error("Decoding produced incorrect port.")
}
}
func TestConsumerMetadataResponseSuccess(t *testing.T) {
response := ConsumerMetadataResponse{}
testDecodable(t, "success", &response, consumerMetadataResponseSuccess)
if response.Err != NoError {
t.Error("Decoding produced error value where there was none.")
}
if response.CoordinatorId != 0xAB {
t.Error("Decoding produced incorrect coordinator ID.")
}
if response.CoordinatorHost != "foo" {
t.Error("Decoding produced incorrect coordinator host.")
}
if response.CoordinatorPort != 0xCCDD {
t.Error("Decoding produced incorrect coordinator port.")
}
}