mitgliederverwaltung/test/test_helper.exs
Simon c48ac2f432
All checks were successful
continuous-integration/drone/push Build is passing
harden env handling (#481)
Reviewed-on: #481
Co-authored-by: Simon <s.thiessen@local-it.org>
Co-committed-by: Simon <s.thiessen@local-it.org>
2026-04-08 10:40:22 +02:00

19 lines
936 B
Elixir

# Ensure tests never hit the real Vereinfacht API (e.g. when .env is loaded by just).
# Tests that need "configured" sync set a fake URL (127.0.0.1:1) in their own setup.
System.delete_env("VEREINFACHT_API_URL")
System.delete_env("VEREINFACHT_API_KEY")
System.delete_env("VEREINFACHT_CLUB_ID")
# Mv.Config.oidc_* reads ENV before database Settings (see lib/mv/config.ex). If a developer
# or CI loads .env with OIDC variables, OidcOnlySignInRedirect and oidc_configured?/0 would
# ignore Membership settings and tests become flaky. Tests that need OIDC env (e.g. group
# claim) set it in setup and restore via on_exit.
~w(OIDC_CLIENT_ID OIDC_BASE_URL OIDC_REDIRECT_URI OIDC_CLIENT_SECRET OIDC_CLIENT_SECRET_FILE OIDC_ONLY OIDC_ADMIN_GROUP_NAME OIDC_GROUPS_CLAIM)
|> Enum.each(&System.delete_env/1)
ExUnit.start(
# shows 10 slowest tests at the end of the test run
# slowest: 10
)
Ecto.Adapters.SQL.Sandbox.mode(Mv.Repo, :manual)