Skip to content

Commit

Permalink
Increase receive timeout for integration test (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
edennis committed May 16, 2023
1 parent ae5d0a1 commit 84052c6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/broadway_sqs/integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ defmodule BroadwaySQS.BroadwaySQS.IntegrationTest do
</DeleteMessageBatchResponse>
"""

defmodule RequestConter do
defmodule RequestCounter do
use Agent

def start_link(counters) do
Expand Down Expand Up @@ -117,15 +117,15 @@ defmodule BroadwaySQS.BroadwaySQS.IntegrationTest do
response =
case body do
"Action=ReceiveMessage" <> _rest ->
if RequestConter.count_for(:receive_message) > 5 do
if RequestCounter.count_for(:receive_message) > 5 do
@receive_message_empty_response
else
RequestConter.increment_for(:receive_message)
RequestCounter.increment_for(:receive_message)
@receive_message_response
end

"Action=DeleteMessageBatch" <> _rest ->
RequestConter.increment_for(:delete_message_batch)
RequestCounter.increment_for(:delete_message_batch)
send(us, :messages_deleted)
@delete_message_response
end
Expand All @@ -135,11 +135,11 @@ defmodule BroadwaySQS.BroadwaySQS.IntegrationTest do
|> Conn.resp(200, response)
end)

{:ok, _} = RequestConter.start_link(%{receive_message: 0, delete_message_batch: 0})
{:ok, _} = RequestCounter.start_link(%{receive_message: 0, delete_message_batch: 0})

{:ok, _consumer} = start_fake_consumer(bypass)

assert_receive {:message_handled, "hello world", %{receipt_handle: "receipt-handle-1"}}
assert_receive {:message_handled, "hello world", %{receipt_handle: "receipt-handle-1"}}, 1_000
assert_receive {:message_handled, "how are you?", %{receipt_handle: "receipt-handle-2"}}

assert_receive {:batch_handled, _messages}
Expand All @@ -148,8 +148,8 @@ defmodule BroadwaySQS.BroadwaySQS.IntegrationTest do
assert_receive :messages_deleted
assert_receive :messages_deleted

assert RequestConter.count_for(:receive_message) == 6
assert RequestConter.count_for(:delete_message_batch) == 3
assert RequestCounter.count_for(:receive_message) == 6
assert RequestCounter.count_for(:delete_message_batch) == 3
end

defp start_fake_consumer(bypass) do
Expand Down

0 comments on commit 84052c6

Please sign in to comment.