Skip to content

Commit

Permalink
fix flaky TestEventProcessor_handler_group (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
roblaszczak authored Jan 8, 2025
1 parent c6d49d0 commit 7ff9f49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/cqrs/command_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ func TestCommandProcessor_multiple_same_command_handlers(t *testing.T) {
}

type mockSubscriber struct {
MessagesToSend []*message.Message
out chan *message.Message
MessagesToSend []*message.Message
WaitForAckBeforeSendingNext bool

out chan *message.Message
}

func (m *mockSubscriber) Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error) {
Expand All @@ -188,6 +190,10 @@ func (m *mockSubscriber) Subscribe(ctx context.Context, topic string) (<-chan *m
go func() {
for _, msg := range m.MessagesToSend {
m.out <- msg

if m.WaitForAckBeforeSendingNext {
<-msg.Acked()
}
}
}()

Expand Down
1 change: 1 addition & 0 deletions components/cqrs/event_processor_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func TestEventProcessor_handler_group(t *testing.T) {
msg1,
msg2,
},
WaitForAckBeforeSendingNext: true,
}

var handlersCalls []int
Expand Down

0 comments on commit 7ff9f49

Please sign in to comment.