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

Function TestClientProduce

produce_test.go:44–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestClientProduce(t *testing.T) {
45 client, topic, shutdown := newLocalClientAndTopic()
46 defer shutdown()
47
48 now := time.Now()
49
50 res, err := client.Produce(context.Background(), &ProduceRequest{
51 Topic: topic,
52 Partition: 0,
53 RequiredAcks: -1,
54 Records: NewRecordReader(
55 Record{Time: now, Value: NewBytes([]byte(`hello-1`))},
56 Record{Time: now, Value: NewBytes([]byte(`hello-2`))},
57 Record{Time: now, Value: NewBytes([]byte(`hello-3`))},
58 ),
59 })
60
61 if err != nil {
62 t.Fatal(err)
63 }
64
65 if res.Error != nil {
66 t.Error(res.Error)
67 }
68
69 for index, err := range res.RecordErrors {
70 t.Errorf("record at index %d produced an error: %v", index, err)
71 }
72}
73
74func TestClientProduceCompressed(t *testing.T) {
75 client, topic, shutdown := newLocalClientAndTopic()

Callers

nothing calls this directly

Calls 5

ProduceMethod · 0.80
newLocalClientAndTopicFunction · 0.70
NewRecordReaderFunction · 0.70
NewBytesFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected