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

Function TestConsumerMeetsErrorsDrainedExpectation

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

Source from the content-addressed store, hash-verified

252}
253
254func TestConsumerMeetsErrorsDrainedExpectation(t *testing.T) {
255 trm := newTestReporterMock()
256 consumer := NewConsumer(trm, NewTestConfig())
257
258 consumer.ExpectConsumePartition("test", 0, sarama.OffsetOldest).
259 YieldError(sarama.ErrInvalidMessage).
260 YieldError(sarama.ErrInvalidMessage).
261 ExpectErrorsDrainedOnClose()
262
263 pc, err := consumer.ConsumePartition("test", 0, sarama.OffsetOldest)
264 if err != nil {
265 t.Error(err)
266 }
267
268 // consume first and second error,
269 <-pc.Errors()
270 <-pc.Errors()
271
272 if err := consumer.Close(); err != nil {
273 t.Error(err)
274 }
275
276 if len(trm.errors) != 0 {
277 t.Errorf("Expected no expectation failures to be set on the error reporter.")
278 }
279}
280
281func TestConsumerTopicMetadata(t *testing.T) {
282 trm := newTestReporterMock()

Callers

nothing calls this directly

Calls 11

ConsumePartitionMethod · 0.95
CloseMethod · 0.95
newTestReporterMockFunction · 0.85
YieldErrorMethod · 0.80
NewConsumerFunction · 0.70
NewTestConfigFunction · 0.70
ErrorMethod · 0.65
ErrorsMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected