Files
parrhesia/test/support/integration_case.ex
Steffen Beyer f4d94c9fcb
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
Refactor test runtime ownership
2026-03-17 12:06:32 +01:00

44 lines
831 B
Elixir

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