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

Function TestConsumerOffsetsAreManagedCorrectlyWithOffsetOldest

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

Source from the content-addressed store, hash-verified

335}
336
337func TestConsumerOffsetsAreManagedCorrectlyWithOffsetOldest(t *testing.T) {
338 trm := newTestReporterMock()
339 consumer := NewConsumer(trm, NewTestConfig())
340 pcmock := consumer.ExpectConsumePartition("test", 0, sarama.OffsetOldest)
341 pcmock.YieldMessage(&sarama.ConsumerMessage{Value: []byte("hello")})
342 pcmock.YieldMessage(&sarama.ConsumerMessage{Value: []byte("hello")})
343 pcmock.ExpectMessagesDrainedOnClose()
344
345 pc, err := consumer.ConsumePartition("test", 0, sarama.OffsetOldest)
346 if err != nil {
347 t.Error(err)
348 }
349
350 message1 := <-pc.Messages()
351 if message1.Offset != 0 {
352 t.Errorf("Expected offset of first message in the partition to be 0, got %d", message1.Offset)
353 }
354
355 message2 := <-pc.Messages()
356 if message2.Offset != 1 {
357 t.Errorf("Expected offset of second message in the partition to be 1, got %d", message2.Offset)
358 }
359
360 if err := consumer.Close(); err != nil {
361 t.Error(err)
362 }
363
364 if len(trm.errors) != 0 {
365 t.Errorf("Expected to not report any errors, found: %v", trm.errors)
366 }
367}
368
369func TestConsumerOffsetsAreManagedCorrectlyWithSpecifiedOffset(t *testing.T) {
370 startingOffset := int64(123)

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