From bb0cacc4deaf0b0fac05f1bbdcdb0da2e832c817 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Bourgeot Date: Wed, 15 Mar 2023 17:14:14 +0100 Subject: [PATCH] WIP: fix existing unit tests --- spec/inputs/sqs_spec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/inputs/sqs_spec.rb b/spec/inputs/sqs_spec.rb index 3de19cb..b929dfe 100644 --- a/spec/inputs/sqs_spec.rb +++ b/spec/inputs/sqs_spec.rb @@ -110,8 +110,8 @@ # We have to make sure we create a bunch of events # so we actually really try to stop the plugin. - # - # rspec's `and_yield` allow you to define a fix amount of possible + # + # rspec's `and_yield` allow you to define a fix amount of possible # yielded values and doesn't allow you to create infinite loop. # And since we are actually creating thread we need to make sure # we have enough work to keep the thread working until we kill it.. @@ -140,10 +140,11 @@ def poll(polling_options = {}) let(:id_field) { "my_id_field" } let(:md5_field) { "my_md5_field" } let(:sent_timestamp_field) { "my_sent_timestamp_field" } + let(:user_attributes_field) { "my_user_attributes_field" } let(:message) do double("message", :message_id => message_id, :md5_of_body => md5_of_body, :attributes => { LogStash::Inputs::SQS::SENT_TIMESTAMP => epoch_timestamp } ) - end + end subject { input.add_sqs_data(event, message) } @@ -198,7 +199,7 @@ def poll(polling_options = {}) end context "receiving messages" do - before do + before do expect(subject).to receive(:poller).and_return(mock_sqs).at_least(:once) end @@ -235,7 +236,7 @@ def poll(polling_options = {}) it "retry to fetch messages" do # change the poller implementation to raise SQS errors. had_error = false - + # actually using the child of `Object` to do an expectation of `#sleep` expect(subject).to receive(:sleep).with(LogStash::Inputs::SQS::BACKOFF_SLEEP_TIME) expect(mock_sqs).to receive(:poll).with(anything()).at_most(2) do