From 2862dc1f5ac87680ff50e5336d2274f9856a0ccb Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 22 Sep 2023 13:22:37 +0200 Subject: [PATCH] cleanup --- .../vendors/datadog/metrics_listener_spec.rb | 2 +- spec/lib/waterdrop/producer/async_spec.rb | 10 ++++++---- spec/lib/waterdrop/producer/sync_spec.rb | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb b/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb index b1a14069..ccd42c21 100644 --- a/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb +++ b/spec/lib/waterdrop/instrumentation/vendors/datadog/metrics_listener_spec.rb @@ -96,7 +96,7 @@ def initialize let(:counts) { dummy_client.buffer[:count] } let(:histograms) { dummy_client.buffer[:histogram] } let(:guages) { dummy_client.buffer[:gauge] } - let(:broker_tag) { { tags: %w[broker:localhost:9092] } } + let(:broker_tag) { { tags: %w[broker:127.0.0.1:9092] } } # We add all expectations in one example not to sleep each time it 'expect to have proper metrics in place' do diff --git a/spec/lib/waterdrop/producer/async_spec.rb b/spec/lib/waterdrop/producer/async_spec.rb index 42e50457..5da5a475 100644 --- a/spec/lib/waterdrop/producer/async_spec.rb +++ b/spec/lib/waterdrop/producer/async_spec.rb @@ -27,7 +27,11 @@ end context 'when producing with good middleware' do + let(:message) { build(:valid_message, payload: nil) } + before do + producer.produce_sync(topic: message[:topic], payload: nil) + mid = lambda do |msg| msg[:partition_key] = '1' msg @@ -36,12 +40,12 @@ producer.middleware.append mid end - let(:message) { build(:valid_message, payload: nil) } - it { expect(delivery).to be_a(Rdkafka::Producer::DeliveryHandle) } end context 'when producing with corrupted middleware' do + let(:message) { build(:valid_message, payload: nil) } + before do mid = lambda do |msg| msg[:partition_key] = -1 @@ -51,8 +55,6 @@ producer.middleware.append mid end - let(:message) { build(:valid_message, payload: nil) } - it { expect { delivery }.to raise_error(WaterDrop::Errors::MessageInvalidError) } end diff --git a/spec/lib/waterdrop/producer/sync_spec.rb b/spec/lib/waterdrop/producer/sync_spec.rb index 266d8241..f3e663d9 100644 --- a/spec/lib/waterdrop/producer/sync_spec.rb +++ b/spec/lib/waterdrop/producer/sync_spec.rb @@ -58,6 +58,8 @@ let(:message) { build(:valid_message, partition_key: rand.to_s, topic: 'example_topic') } + before { producer.produce_sync(topic: 'example_topic', payload: '1') } + it { expect(delivery).to be_a(Rdkafka::Producer::DeliveryReport) } end