Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fail fast in host mode if PG* connection env is set

Manav Rathi3c7c58cc344f
diff --git a/server/scripts/test-with-postgres.sh b/server/scripts/test-with-postgres.sh
index bd71013d57..1a12165513 100755
--- a/server/scripts/test-with-postgres.sh
+++ b/server/scripts/test-with-postgres.sh
@@ -41,9 +41,11 @@ if [ "$mode" = docker ]; then
done
export PGHOST=localhost PGPORT="$port" PGUSER=postgres PGPASSWORD=test_pass
else
- # psql defaults to the unix socket while lib/pq defaults to TCP
- # localhost; pin both to the same server.
- [ -n "${PGHOST:-}" ] || export PGHOST=localhost
+ [ -z "${PGHOST:-}${PGHOSTADDR:-}${PGPORT:-}${PGSERVICE:-}${PGSERVICEFILE:-}" ] || {
+ echo "host mode always uses the default local Postgres; unset PG* env." >&2
+ exit 1
+ }
+ export PGHOST=localhost
psql -qd postgres -c "CREATE DATABASE \"$test_db\""
trap 'psql -qd postgres -c "DROP DATABASE IF EXISTS \"$test_db\" WITH (FORCE)" >/dev/null 2>&1 || true' EXIT INT TERM
fi