Refactor test runtime ownership
Some checks failed
CI / Test (OTP 27.2 / Elixir 1.18.2) (push) Failing after 0s
CI / Test (OTP 28.4 / Elixir 1.19.4 + Marmot E2E) (push) Failing after 0s

This commit is contained in:
2026-03-17 12:06:32 +01:00
parent 35c8d50db0
commit f4d94c9fcb
37 changed files with 142 additions and 247 deletions

34
test/support/runtime.ex Normal file
View File

@@ -0,0 +1,34 @@
defmodule Parrhesia.TestSupport.Runtime do
@moduledoc false
@required_processes [
Parrhesia.Supervisor,
Parrhesia.Config,
Parrhesia.Repo,
Parrhesia.Subscriptions.Supervisor,
Parrhesia.Web.Endpoint
]
def ensure_started! do
if healthy?() do
:ok
else
restart!()
end
end
defp healthy? do
Enum.all?(@required_processes, &is_pid(Process.whereis(&1)))
end
defp restart! do
case Application.stop(:parrhesia) do
:ok -> :ok
{:error, {:not_started, :parrhesia}} -> :ok
{:error, {:not_started, _app}} -> :ok
end
{:ok, _apps} = Application.ensure_all_started(:parrhesia)
:ok
end
end