Skip to content

Commit

Permalink
add reaper start_link in helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 15, 2023
1 parent 3bb461c commit 8b93f71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
20 changes: 4 additions & 16 deletions lib/reaper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ExUnit.configure(max_cases: System.schedulers_online() * 4)
TestcontainersElixir.Reaper.start_link()
ExUnit.start()

0 comments on commit 8b93f71

Please sign in to comment.