Skip to content

Commit

Permalink
more specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mensfeld committed Oct 22, 2023
1 parent 950474a commit d2d7997
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion spec/lib/waterdrop/producer/transactions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
subject(:producer) { build(:transactional_producer) }

let(:transactional_id) { SecureRandom.uuid }
let(:critical_error) { Exception }

after { producer.close }

Expand Down Expand Up @@ -197,6 +198,36 @@
end
end

context 'when we start transaction and raise a critical Exception' do
it 'expect to re-raise this error' do
expect do
producer.transaction do
producer.produce_async(topic: 'example_topic', payload: 'na')

raise critical_error
end
end.to raise_error(critical_error)
end

it 'expect to cancel the dispatch of the message' do
handler = nil

begin
producer.transaction do
handler = producer.produce_async(topic: 'example_topic', payload: 'na')

raise critical_error
end
rescue critical_error
nil
end

expect { handler.wait }.to raise_error(Rdkafka::RdkafkaError, /Purged in queue/)
end

# The rest is expected to behave the same way as StandardError so not duplicating
end

context 'when we start transaction and abort' do
it 'expect not to re-raise' do
expect do
Expand Down Expand Up @@ -321,7 +352,7 @@
end
end

context 'when trying to close a producer fron a different thread during transaction' do
context 'when trying to close a producer from a different thread during transaction' do
it 'expect to raise an error' do
expect do
producer.transaction do
Expand Down

0 comments on commit d2d7997

Please sign in to comment.