Files

75 lines
2.2 KiB
Elixir
Raw Permalink Normal View History

2026-07-04 18:05:14 +09:00
import Config
# Configure your database
#
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
2026-07-04 19:27:17 +09:00
#
# When DATABASE_URL is set (see .env) we reuse its server but connect to a
# dedicated "<db>_test" database so tests never touch development data.
partition = System.get_env("MIX_TEST_PARTITION")
if url = System.get_env("DATABASE_URL") do
uri = URI.parse(url)
{username, password} =
case uri.userinfo do
nil ->
{"postgres", "postgres"}
info ->
case String.split(info, ":", parts: 2) do
[u, p] -> {u, p}
[u] -> {u, nil}
end
end
base = uri.path |> to_string() |> String.trim_leading("/")
base = if base == "", do: "rsh26pool", else: base
config :rsh26pool, Rsh26pool.Repo,
username: username,
password: password,
hostname: uri.host || "localhost",
port: uri.port || 5432,
database: "#{base}_test#{partition}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: System.schedulers_online() * 2
else
config :rsh26pool, Rsh26pool.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "rsh26pool_test#{partition}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: System.schedulers_online() * 2
end
2026-07-04 18:05:14 +09:00
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :rsh26pool, Rsh26poolWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
secret_key_base: "5Tb/Dozy0Z1vW10bsuLjJRzuZeQ/W0+W9i/u2sZ9sXUUmWEOQr+bbx3KZE+WN3s8",
server: false
# In test we don't send emails
config :rsh26pool, Rsh26pool.Mailer, adapter: Swoosh.Adapters.Test
# Disable swoosh api client as it is only required for production adapters
config :swoosh, :api_client, false
# Print only warnings and errors during test
config :logger, level: :warning
# Initialize plugs at runtime for faster test compilation
config :phoenix, :plug_init_mode, :runtime
# Enable helpful, but potentially expensive runtime checks
config :phoenix_live_view,
enable_expensive_runtime_checks: true
# Sort query params output of verified routes for robust url comparisons
config :phoenix,
sort_verified_routes_query_params: true