oneshot
This commit is contained in:
+40
-7
@@ -5,13 +5,46 @@ import Config
|
||||
# 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.
|
||||
config :rsh26pool, Rsh26pool.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
hostname: "localhost",
|
||||
database: "rsh26pool_test#{System.get_env("MIX_TEST_PARTITION")}",
|
||||
pool: Ecto.Adapters.SQL.Sandbox,
|
||||
pool_size: System.schedulers_online() * 2
|
||||
#
|
||||
# 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
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
|
||||
Reference in New Issue
Block a user