fix: use rotated database credentials in tests
This commit is contained in:
parent
bd448f5afd
commit
30bfeef1fb
|
|
@ -9,8 +9,8 @@ config :bcrypt_elixir, :log_rounds, 1
|
|||
# to provide built-in test partitioning in CI environment.
|
||||
# Run `mix help test` for more information.
|
||||
config :who_need_help, WhoNeedHelp.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
username: System.get_env("DB_USER", "postgres"),
|
||||
password: System.get_env("DB_PASSWORD"),
|
||||
hostname: System.get_env("DB_HOST", "localhost"),
|
||||
port: String.to_integer(System.get_env("DB_PORT", "5432")),
|
||||
database: "who_need_help_test#{System.get_env("MIX_TEST_PARTITION")}",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,18 @@ set -eu
|
|||
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$ROOT"
|
||||
|
||||
if [ ! -f "$ROOT/.env" ]; then
|
||||
echo "Missing $ROOT/.env. Copy .env.example to .env first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -a
|
||||
. "$ROOT/.env"
|
||||
set +a
|
||||
|
||||
: "${POSTGRES_USER:?Set POSTGRES_USER in .env}"
|
||||
: "${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}"
|
||||
|
||||
docker compose -p who_need_help up -d --wait db
|
||||
docker build --target test --tag who-need-help:test .
|
||||
|
||||
|
|
@ -11,6 +23,8 @@ exec docker run --rm \
|
|||
--network who_need_help_internal \
|
||||
--env MIX_ENV=test \
|
||||
--env DB_HOST=db \
|
||||
--env "DB_USER=$POSTGRES_USER" \
|
||||
--env "DB_PASSWORD=$POSTGRES_PASSWORD" \
|
||||
--env TEST_POOL_SIZE="${TEST_POOL_SIZE:-10}" \
|
||||
who-need-help:test \
|
||||
mix test
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user