Skip to content

Commit

Permalink
WIP: fix existing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
piequi committed Mar 15, 2023
1 parent c5af410 commit bb0cacc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions spec/inputs/sqs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand Down Expand Up @@ -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) }

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb0cacc

Please sign in to comment.