forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_topics_request_test.go
50 lines (42 loc) · 1 KB
/
create_topics_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
49
50
package sarama
import (
"testing"
"time"
)
var (
createTopicsRequestV0 = []byte{
0, 0, 0, 1,
0, 5, 't', 'o', 'p', 'i', 'c',
255, 255, 255, 255,
255, 255,
0, 0, 0, 1, // 1 replica assignment
0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2,
0, 0, 0, 1, // 1 config
0, 12, 'r', 'e', 't', 'e', 'n', 't', 'i', 'o', 'n', '.', 'm', 's',
0, 2, '-', '1',
0, 0, 0, 100,
}
createTopicsRequestV1 = append(createTopicsRequestV0, byte(1))
)
func TestCreateTopicsRequest(t *testing.T) {
retention := "-1"
req := &CreateTopicsRequest{
TopicDetails: map[string]*TopicDetail{
"topic": {
NumPartitions: -1,
ReplicationFactor: -1,
ReplicaAssignment: map[int32][]int32{
0: {0, 1, 2},
},
ConfigEntries: map[string]*string{
"retention.ms": &retention,
},
},
},
Timeout: 100 * time.Millisecond,
}
testRequest(t, "version 0", req, createTopicsRequestV0)
req.Version = 1
req.ValidateOnly = true
testRequest(t, "version 1", req, createTopicsRequestV1)
}