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

Function TestConsumerReturnsNonconsumedErrorsOnClose

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

Source from the content-addressed store, hash-verified

148}
149
150func TestConsumerReturnsNonconsumedErrorsOnClose(t *testing.T) {
151 consumer := NewConsumer(t, NewTestConfig())
152 consumer.ExpectConsumePartition("test", 0, sarama.OffsetOldest).YieldError(sarama.ErrOutOfBrokers)
153 consumer.ExpectConsumePartition("test", 0, sarama.OffsetOldest).YieldError(sarama.ErrOutOfBrokers)
154
155 pc, err := consumer.ConsumePartition("test", 0, sarama.OffsetOldest)
156 if err != nil {
157 t.Fatal(err)
158 }
159
160 select {
161 case <-pc.Messages():
162 t.Error("Did not expect a message on the messages channel.")
163 case err := <-pc.Errors():
164 if !errors.Is(err, sarama.ErrOutOfBrokers) {
165 t.Error("Expected sarama.ErrOutOfBrokers, found", err)
166 }
167 }
168
169 var errs sarama.ConsumerErrors
170 if !errors.As(pc.Close(), &errs) {
171 t.Error("Expected Close to return ConsumerErrors")
172 }
173 if len(errs) != 1 && !errors.Is(errs[0], sarama.ErrOutOfBrokers) {
174 t.Error("Expected Close to return the remaining sarama.ErrOutOfBrokers")
175 }
176}
177
178func TestConsumerWithoutExpectationsOnPartition(t *testing.T) {
179 trm := newTestReporterMock()

Callers

nothing calls this directly

Calls 11

ConsumePartitionMethod · 0.95
YieldErrorMethod · 0.80
FatalMethod · 0.80
IsMethod · 0.80
NewConsumerFunction · 0.70
NewTestConfigFunction · 0.70
MessagesMethod · 0.65
ErrorMethod · 0.65
ErrorsMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected