Skip to content

Commit

Permalink
Add test for 'one-at-a-time' send request
Browse files Browse the repository at this point in the history
  • Loading branch information
bokner committed Jul 11, 2023
1 parent 43489e5 commit a4b1fae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,23 @@ defmodule ClientTest do
assert {:error, %Error{message: "connection closed", context: :send, reason: :closed}} ==
Client.send(client, message)
end

test "one send request at a time", ctx do
test_message = "test_one_send_at_a_time"

concurrent_requests =
Task.async_stream(1..2, fn _i -> Client.send(ctx.client, test_message) end)
|> Enum.map(fn {:ok, res} -> res end)

assert length(concurrent_requests) == 2

assert Enum.count(concurrent_requests, fn resp ->
case resp do
{:ok, message} when message == test_message -> true
{:error, :busy_with_other_call} -> false
end
end) == 1
end
end

describe "send_async/2" do
Expand Down

0 comments on commit a4b1fae

Please sign in to comment.