Skip to content

Commit 2c97e75

Browse files
author
Marc-Antoine Bourgeot
committed
WIP: fix existing unit tests
1 parent c5af410 commit 2c97e75

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

spec/inputs/sqs_spec.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
let(:input) { LogStash::Inputs::SQS.new(config) }
2424
let(:decoded_message) { { "bonjour" => "awesome" } }
25-
let(:encoded_message) { double("sqs_message", :body => LogStash::Json::dump(decoded_message)) }
25+
let(:encoded_message) { double("sqs_message", :body => LogStash::Json::dump(decoded_message)), :message_attributes => {} }
2626

2727
subject { input }
2828

@@ -110,8 +110,8 @@
110110

111111
# We have to make sure we create a bunch of events
112112
# so we actually really try to stop the plugin.
113-
#
114-
# rspec's `and_yield` allow you to define a fix amount of possible
113+
#
114+
# rspec's `and_yield` allow you to define a fix amount of possible
115115
# yielded values and doesn't allow you to create infinite loop.
116116
# And since we are actually creating thread we need to make sure
117117
# we have enough work to keep the thread working until we kill it..
@@ -136,14 +136,16 @@ def poll(polling_options = {})
136136
let(:md5_of_body) { "dr strange" }
137137
let(:sent_timestamp) { LogStash::Timestamp.new }
138138
let(:epoch_timestamp) { (sent_timestamp.utc.to_f * 1000).to_i }
139+
let(:message_attributes) { :some_metadata => "add this" }
139140

140141
let(:id_field) { "my_id_field" }
141142
let(:md5_field) { "my_md5_field" }
142143
let(:sent_timestamp_field) { "my_sent_timestamp_field" }
144+
let(:user_attributes_field) { "my_user_attributes_field" }
143145

144146
let(:message) do
145-
double("message", :message_id => message_id, :md5_of_body => md5_of_body, :attributes => { LogStash::Inputs::SQS::SENT_TIMESTAMP => epoch_timestamp } )
146-
end
147+
double("message", :message_id => message_id, :md5_of_body => md5_of_body, :attributes => { LogStash::Inputs::SQS::SENT_TIMESTAMP => epoch_timestamp }, :message_attributes => message_attributes )
148+
end
147149

148150
subject { input.add_sqs_data(event, message) }
149151

@@ -156,7 +158,8 @@ def poll(polling_options = {})
156158
"queue" => queue_name,
157159
"id_field" => id_field,
158160
"md5_field" => md5_field,
159-
"sent_timestamp_field" => sent_timestamp_field
161+
"sent_timestamp_field" => sent_timestamp_field,
162+
"user_attributes_field" => user_attributes_field
160163
}
161164
end
162165

@@ -198,7 +201,7 @@ def poll(polling_options = {})
198201
end
199202

200203
context "receiving messages" do
201-
before do
204+
before do
202205
expect(subject).to receive(:poller).and_return(mock_sqs).at_least(:once)
203206
end
204207

@@ -235,7 +238,7 @@ def poll(polling_options = {})
235238
it "retry to fetch messages" do
236239
# change the poller implementation to raise SQS errors.
237240
had_error = false
238-
241+
239242
# actually using the child of `Object` to do an expectation of `#sleep`
240243
expect(subject).to receive(:sleep).with(LogStash::Inputs::SQS::BACKOFF_SLEEP_TIME)
241244
expect(mock_sqs).to receive(:poll).with(anything()).at_most(2) do

0 commit comments

Comments
 (0)