Skip to content

Commit

Permalink
feature: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmtszr committed Dec 2, 2023
1 parent 986f527 commit 3301839
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions batch_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ func Test_batchConsumer_startBatch(t *testing.T) {
// Given
var numberOfBatch int

mc := mockReader{}
bc := batchConsumer{
base: &base{
messageCh: make(chan *Message),
metric: &ConsumerMetric{},
wg: sync.WaitGroup{},
messageGroupDuration: 500 * time.Millisecond,
r: &mc,
},
messageGroupLimit: 3,
consumeFn: func(messages []*Message) error {
Expand Down
10 changes: 8 additions & 2 deletions consumer_base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,15 @@ func (m *mockReader) FetchMessage(ctx context.Context) (*kafka.Message, error) {
}

func (m *mockReader) Close() error {
panic("implement me")
if m.wantErr {
return errors.New("err")
}
return nil
}

func (m *mockReader) CommitMessages(messages []kafka.Message) error {
panic("implement me")
if m.wantErr {
return errors.New("err")
}
return nil
}

0 comments on commit 3301839

Please sign in to comment.