MCPcopy
hub / github.com/IBM/sarama / TestProduceSetRequestBuilding

Function TestProduceSetRequestBuilding

produce_set_test.go:138–174  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestProduceSetRequestBuilding(t *testing.T) {
139 parent, ps := makeProduceSet()
140 parent.conf.Producer.RequiredAcks = WaitForAll
141 parent.conf.Producer.Timeout = 10 * time.Second
142
143 msg := &ProducerMessage{
144 Topic: "t1",
145 Partition: 0,
146 Key: StringEncoder(TestMessage),
147 Value: StringEncoder(TestMessage),
148 }
149 for range 10 {
150 safeAddMessage(t, ps, msg)
151 }
152 msg.Partition = 1
153 for range 10 {
154 safeAddMessage(t, ps, msg)
155 }
156 msg.Topic = "t2"
157 for range 10 {
158 safeAddMessage(t, ps, msg)
159 }
160
161 req := ps.buildRequest()
162
163 if req.RequiredAcks != WaitForAll {
164 t.Error("RequiredAcks not set properly")
165 }
166
167 if req.Timeout != 10000 {
168 t.Error("Timeout not set properly")
169 }
170
171 if len(req.records) != 2 {
172 t.Error("Wrong number of topics in request")
173 }
174}
175
176func TestProduceSetCompressedRequestBuilding(t *testing.T) {
177 parent, ps := makeProduceSet()

Callers

nothing calls this directly

Calls 5

makeProduceSetFunction · 0.85
StringEncoderTypeAlias · 0.85
safeAddMessageFunction · 0.85
buildRequestMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected