From 8b93f71bb5fb90332fd17334ec1c95cfa52e405a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarl=20Andr=C3=A9=20H=C3=BCbenthal?= Date: Sun, 15 Oct 2023 12:53:04 +0200 Subject: [PATCH] add reaper start_link in helper --- lib/reaper.ex | 20 ++++---------------- test/test_helper.exs | 1 + 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/reaper.ex b/lib/reaper.ex index f19fd22..9f0242b 100644 --- a/lib/reaper.ex +++ b/lib/reaper.ex @@ -15,8 +15,10 @@ defmodule TestcontainersElixir.Reaper do end def register(filter) do - :ok = ensure_reaper_is_alive() - GenServer.call(__MODULE__, {:register, filter}, 10000) + case GenServer.whereis(__MODULE__) do + nil -> IO.puts("Reaper is not configured, add it to test_helper.exs with TestcontainersElixir.Reaper.start_link()") + _pid -> GenServer.call(__MODULE__, {:register, filter}, 5000) + end end @impl true @@ -79,18 +81,4 @@ defmodule TestcontainersElixir.Reaper do packet: :line ]) end - - defp ensure_reaper_is_alive() do - case __MODULE__.start_link() do - {:error, {:already_started, _}} -> - :ok - - {:ok, _} -> - :ok - - other -> - IO.puts("Ignoring unexpected result from starting reaper: #{inspect(other)}") - :ok - end - end end diff --git a/test/test_helper.exs b/test/test_helper.exs index 12cdafd..4f55472 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,2 +1,3 @@ ExUnit.configure(max_cases: System.schedulers_online() * 4) +TestcontainersElixir.Reaper.start_link() ExUnit.start()