Skip to content

Commit

Permalink
test: less finicky http1 pool tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zachallaun committed Jun 11, 2023
1 parent f53e8e4 commit 4d259b6
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions test/finch/http1/pool_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,19 @@ defmodule Finch.HTTP1.PoolTest do
test "canceled if calling process exits normally", %{finch_name: finch_name, url: url} do
outer = self()

caller =
spawn(fn ->
ref =
Finch.build(:get, url <> "/stream/5/500")
|> Finch.async_request(finch_name)
spawn(fn ->
ref =
Finch.build(:get, url <> "/stream/5/500")
|> Finch.async_request(finch_name)

# allow process to exit normally after sending
send(outer, ref)
end)
# allow process to exit normally after sending
send(outer, ref)
end)

assert_receive {Finch.HTTP1.Pool, pid} when is_pid(pid)

Process.sleep(100)
refute Process.alive?(caller)
refute Process.alive?(pid)
ref = Process.monitor(pid)
assert_receive {:DOWN, ^ref, _, _, _}, 500
end

test "canceled if calling process exits abnormally", %{finch_name: finch_name, url: url} do
Expand All @@ -136,10 +134,9 @@ defmodule Finch.HTTP1.PoolTest do

assert_receive {Finch.HTTP1.Pool, pid} when is_pid(pid)

ref = Process.monitor(pid)
Process.exit(caller, :shutdown)
Process.sleep(100)
refute Process.alive?(caller)
refute Process.alive?(pid)
assert_receive {:DOWN, ^ref, _, _, _}, 500
end
end
end

0 comments on commit 4d259b6

Please sign in to comment.