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

Function testWriterRoundRobin1

writer_test.go:268–308  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

266}
267
268func testWriterRoundRobin1(t *testing.T) {
269 const topic = "test-writer-1"
270 createTopic(t, topic, 1)
271 defer deleteTopic(t, topic)
272
273 offset, err := readOffset(topic, 0)
274 if err != nil {
275 t.Fatal(err)
276 }
277
278 w := newTestWriter(WriterConfig{
279 Topic: topic,
280 Balancer: &RoundRobin{},
281 })
282 defer w.Close()
283
284 if err := w.WriteMessages(context.Background(), Message{
285 Value: []byte("Hello World!"),
286 }); err != nil {
287 t.Error(err)
288 return
289 }
290
291 msgs, err := readPartition(topic, 0, offset)
292 if err != nil {
293 t.Error("error reading partition", err)
294 return
295 }
296
297 if len(msgs) != 1 {
298 t.Error("bad messages in partition", msgs)
299 return
300 }
301
302 for _, m := range msgs {
303 if string(m.Value) != "Hello World!" {
304 t.Error("bad messages in partition", msgs)
305 break
306 }
307 }
308}
309
310func TestValidateWriter(t *testing.T) {
311 tests := []struct {

Callers

nothing calls this directly

Calls 8

createTopicFunction · 0.85
deleteTopicFunction · 0.85
readOffsetFunction · 0.85
newTestWriterFunction · 0.85
readPartitionFunction · 0.85
CloseMethod · 0.45
WriteMessagesMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected