MCPcopy
hub / github.com/segmentio/kafka-go / TestClientCreateTopics

Function TestClientCreateTopics

createtopics_test.go:87–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestClientCreateTopics(t *testing.T) {
88 const (
89 topic1 = "client-topic-1"
90 topic2 = "client-topic-2"
91 topic3 = "client-topic-3"
92 )
93
94 client, shutdown := newLocalClient()
95 defer shutdown()
96
97 config := []ConfigEntry{{
98 ConfigName: "retention.ms",
99 ConfigValue: "3600000",
100 }}
101
102 res, err := client.CreateTopics(context.Background(), &CreateTopicsRequest{
103 Topics: []TopicConfig{
104 {
105 Topic: topic1,
106 NumPartitions: -1,
107 ReplicationFactor: -1,
108 ReplicaAssignments: []ReplicaAssignment{
109 {
110 Partition: 0,
111 Replicas: []int{1},
112 },
113 {
114 Partition: 1,
115 Replicas: []int{1},
116 },
117 {
118 Partition: 2,
119 Replicas: []int{1},
120 },
121 },
122 ConfigEntries: config,
123 },
124 {
125 Topic: topic2,
126 NumPartitions: 2,
127 ReplicationFactor: 1,
128 ConfigEntries: config,
129 },
130 {
131 Topic: topic3,
132 NumPartitions: 1,
133 ReplicationFactor: 1,
134 ConfigEntries: config,
135 },
136 },
137 })
138 if err != nil {
139 t.Fatal(err)
140 }
141
142 defer deleteTopic(t, topic1, topic2, topic3)
143
144 expectTopics := map[string]struct{}{

Callers

nothing calls this directly

Calls 3

deleteTopicFunction · 0.85
newLocalClientFunction · 0.70
CreateTopicsMethod · 0.45

Tested by

no test coverage detected