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

Function TestClientProduceCompressed

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

Source from the content-addressed store, hash-verified

72}
73
74func TestClientProduceCompressed(t *testing.T) {
75 client, topic, shutdown := newLocalClientAndTopic()
76 defer shutdown()
77
78 now := time.Now()
79
80 res, err := client.Produce(context.Background(), &ProduceRequest{
81 Topic: topic,
82 Partition: 0,
83 RequiredAcks: -1,
84 Compression: compress.Gzip,
85 Records: NewRecordReader(
86 Record{Time: now, Value: NewBytes([]byte(`hello-1`))},
87 Record{Time: now, Value: NewBytes([]byte(`hello-2`))},
88 Record{Time: now, Value: NewBytes([]byte(`hello-3`))},
89 ),
90 })
91
92 if err != nil {
93 t.Fatal(err)
94 }
95
96 if res.Error != nil {
97 t.Error(res.Error)
98 }
99
100 for index, err := range res.RecordErrors {
101 t.Errorf("record at index %d produced an error: %v", index, err)
102 }
103}
104
105func TestClientProduceNilRecords(t *testing.T) {
106 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