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

Function TestConsumerViolatesMessagesDrainedExpectation

mocks/consumer_test.go:229–252  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

227}
228
229func TestConsumerViolatesMessagesDrainedExpectation(t *testing.T) {
230 trm := newTestReporterMock()
231 consumer := NewConsumer(trm, NewTestConfig())
232 consumer.ExpectConsumePartition("test", 0, sarama.OffsetOldest).
233 YieldMessage(&sarama.ConsumerMessage{Value: []byte("hello")}).
234 YieldMessage(&sarama.ConsumerMessage{Value: []byte("hello")}).
235 ExpectMessagesDrainedOnClose()
236
237 pc, err := consumer.ConsumePartition("test", 0, sarama.OffsetOldest)
238 if err != nil {
239 t.Error(err)
240 }
241
242 // consume first message, not second one
243 <-pc.Messages()
244
245 if err := consumer.Close(); err != nil {
246 t.Error(err)
247 }
248
249 if len(trm.errors) != 1 {
250 t.Errorf("Expected an expectation failure to be set on the error reporter.")
251 }
252}
253
254func TestConsumerMeetsErrorsDrainedExpectation(t *testing.T) {
255 trm := newTestReporterMock()

Callers

nothing calls this directly

Calls 11

ConsumePartitionMethod · 0.95
CloseMethod · 0.95
newTestReporterMockFunction · 0.85
YieldMessageMethod · 0.80
NewConsumerFunction · 0.70
NewTestConfigFunction · 0.70
ErrorMethod · 0.65
MessagesMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected