(t *testing.T)
| 148 | } |
| 149 | |
| 150 | func 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 | |
| 178 | func TestConsumerWithoutExpectationsOnPartition(t *testing.T) { |
| 179 | trm := newTestReporterMock() |
nothing calls this directly
no test coverage detected