(t *testing.T)
| 227 | } |
| 228 | |
| 229 | func 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 | |
| 254 | func TestConsumerMeetsErrorsDrainedExpectation(t *testing.T) { |
| 255 | trm := newTestReporterMock() |
nothing calls this directly
no test coverage detected