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

Function TestProducerWithCheckerFunction

mocks/async_producer_test.go:189–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

187}
188
189func TestProducerWithCheckerFunction(t *testing.T) {
190 trm := newTestReporterMock()
191 mp := NewAsyncProducer(trm, nil).
192 ExpectInputWithCheckerFunctionAndSucceed(generateRegexpChecker("^tes")).
193 ExpectInputWithCheckerFunctionAndSucceed(generateRegexpChecker("^tes$"))
194
195 mp.Input() <- &sarama.ProducerMessage{Topic: "test", Value: sarama.StringEncoder("test")}
196 mp.Input() <- &sarama.ProducerMessage{Topic: "test", Value: sarama.StringEncoder("test")}
197 if err := mp.Close(); err != nil {
198 t.Error(err)
199 }
200
201 if len(mp.Errors()) != 1 {
202 t.Error("Expected to report an error")
203 }
204
205 err1 := <-mp.Errors()
206 if !strings.HasPrefix(err1.Err.Error(), "No match") {
207 t.Error("Expected to report a value check error, found: ", err1.Err)
208 }
209}
210
211func TestProducerWithBrokenPartitioner(t *testing.T) {
212 trm := newTestReporterMock()

Callers

nothing calls this directly

Calls 9

StringEncoderTypeAlias · 0.92
newTestReporterMockFunction · 0.85
generateRegexpCheckerFunction · 0.85
NewAsyncProducerFunction · 0.70
InputMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65
ErrorsMethod · 0.65

Tested by

no test coverage detected