From 4d259b69ba638938c5afdeee5aab7576977d4bbd Mon Sep 17 00:00:00 2001 From: Zach Allaun Date: Sun, 11 Jun 2023 15:46:57 -0400 Subject: [PATCH] test: less finicky http1 pool tests --- test/finch/http1/pool_test.exs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/finch/http1/pool_test.exs b/test/finch/http1/pool_test.exs index a18a14a2..563d9555 100644 --- a/test/finch/http1/pool_test.exs +++ b/test/finch/http1/pool_test.exs @@ -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 @@ -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