forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata_request_test.go
48 lines (36 loc) · 1.26 KB
/
metadata_request_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
package sarama
import "testing"
var (
metadataRequestNoTopics = []byte{
0x00, 0x00, 0x00, 0x00}
metadataRequestOneTopic = []byte{
0x00, 0x00, 0x00, 0x01,
0x00, 0x06, 't', 'o', 'p', 'i', 'c', '1'}
metadataRequestThreeTopics = []byte{
0x00, 0x00, 0x00, 0x03,
0x00, 0x03, 'f', 'o', 'o',
0x00, 0x03, 'b', 'a', 'r',
0x00, 0x03, 'b', 'a', 'z'}
metadataRequestV1AllTopics = []byte{
0xFF, 0xFF, 0xFF, 0xFF,
}
)
func TestMetadataRequest(t *testing.T) {
request := &MetadataRequest{Version: 0}
testRequest(t, "no topics", request, metadataRequestNoTopics)
request.Topics = []string{"topic1"}
testRequest(t, "one topic", request, metadataRequestOneTopic)
request.Topics = []string{"foo", "bar", "baz"}
testRequest(t, "three topics", request, metadataRequestThreeTopics)
}
func TestMetadataRequestV1(t *testing.T) {
request := &MetadataRequest{Version: 1}
testRequest(t, "no topics", request, metadataRequestNoTopics)
request.AllTopics = true
testRequest(t, "all topics", request, metadataRequestV1AllTopics)
request.AllTopics = false
request.Topics = []string{"topic1"}
testRequest(t, "one topic", request, metadataRequestOneTopic)
request.Topics = []string{"foo", "bar", "baz"}
testRequest(t, "three topics", request, metadataRequestThreeTopics)
}