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

View File

@@ -0,0 +1,43 @@
defmodule Parrhesia.IntegrationCase do
@moduledoc false
use ExUnit.CaseTemplate
alias Ecto.Adapters.SQL.Sandbox
alias ExUnit.Case
alias Parrhesia.Repo
alias Parrhesia.TestSupport.Runtime
using opts do
quote bind_quoted: [opts: opts] do
use Case, async: Keyword.get(opts, :async, false)
alias Ecto.Adapters.SQL.Sandbox
alias Parrhesia.Repo
@moduletag parrhesia_sandbox: Keyword.get(opts, :sandbox, false)
end
end
setup tags do
Runtime.ensure_started!()
case tags[:parrhesia_sandbox] do
false ->
:ok
true ->
:ok = Sandbox.checkout(Repo)
:shared ->
:ok = Sandbox.checkout(Repo)
Sandbox.mode(Repo, {:shared, self()})
on_exit(fn ->
Sandbox.mode(Repo, :manual)
end)
end
:ok
end
end