Skip to content

Commit

Permalink
fix(mock consumer): HighWaterMarkOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
gr8web committed Mar 3, 2023
1 parent 397cee4 commit e47c908
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mocks/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (pc *PartitionConsumer) Messages() <-chan *sarama.ConsumerMessage {
}

func (pc *PartitionConsumer) HighWaterMarkOffset() int64 {
return atomic.LoadInt64(&pc.highWaterMarkOffset) + 1
return atomic.LoadInt64(&pc.highWaterMarkOffset)
}

// Pause implements the Pause method from the sarama.PartitionConsumer interface.
Expand Down
3 changes: 3 additions & 0 deletions mocks/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/Shopify/sarama"
assert "github.com/stretchr/testify/require"
)

func TestMockConsumerImplementsConsumerInterface(t *testing.T) {
Expand Down Expand Up @@ -395,6 +396,8 @@ func TestConsumerOffsetsAreManagedCorrectlyWithSpecifiedOffset(t *testing.T) {
if len(trm.errors) != 0 {
t.Errorf("Expected to not report any errors, found: %v", trm.errors)
}

assert.True(t, pc.HighWaterMarkOffset() == message2.Offset+1)
}

func TestConsumerInvalidConfiguration(t *testing.T) {
Expand Down

0 comments on commit e47c908

Please sign in to comment.