Skip to content

Commit

Permalink
Revert "Unify env var names"
Browse files Browse the repository at this point in the history
This reverts commit 007520a.
  • Loading branch information
amureki committed Oct 16, 2022
1 parent b9e895f commit 640f2ee
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ jobs:
image: postgis/postgis
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

env:
PGPASSWORD: postgres
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
Expand All @@ -33,6 +35,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y gdal-bin
psql -c "CREATE ROLE runner SUPERUSER LOGIN CREATEDB;" -U postgres -h localhost -p 5432
psql template1 -c "CREATE EXTENSION citext;" -U postgres -h localhost -p 5432
psql template1 -c "CREATE EXTENSION hstore;" -U postgres -h localhost -p 5432
psql template1 -c "CREATE EXTENSION postgis;" -U postgres -h localhost -p 5432
Expand Down
10 changes: 5 additions & 5 deletions postgis-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -euo pipefail
### so if you are already running PostgreSQL locally, instead of using this
### script, simply run:
###
### # TEST_DB=postgis POSTGRES_USER=postgres python -m pytest
### # TEST_DB=postgis PGUSER=postgres python -m pytest
###
### This script uses the `python` on the current `$PATH`, but can be overridden
### by setting the `PYTHON_CLI` environment variable.
Expand Down Expand Up @@ -48,9 +48,9 @@ PYTHON=${PYTHON_CLI:-python}
DEPS="$PYTHON"

# Arg defaults
export POSTGRES_PORT=${POSTGRES_PORT:-5432}
export POSTGRES_USER=${POSTGRES_USER:-postgres}
export POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
export PGPORT=${PGPORT:-5432}
export PGUSER=${PGUSER:-postgres}
export PGPASSWORD=${PGPASSWORD:-postgres}
export TEST_DB=${TEST_DB:-postgis}

# Argument parsing using "getopt"
Expand Down Expand Up @@ -110,7 +110,7 @@ for dep in $DEPS; do
done

# Run the postgres container with all extensions installed
$PROJECT_ROOT/postgres-docker --port POSTGRES_PORT
$PROJECT_ROOT/postgres-docker --port $PGPORT

# Run the tests
$PYTHON -m pytest
Expand Down
4 changes: 2 additions & 2 deletions postgres-docker
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DEPS="$DOCKER"
# Arg defaults
KILL=false
CONTAINER_NAME=model-bakery-postgres
PORT=${POSTGRES_PORT:-5432}
PORT=${PGPORT:-5432}

# Argument parsing using "getopt"
OPTIONS=h,k,p
Expand All @@ -66,7 +66,7 @@ eval set -- "$PARSED"
while true; do
case "$1" in
-p|--port)
POSTGRES_PORT=$2
PGPORT=$2
shift
;;
-k|--kill)
Expand Down
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ def pytest_configure():
"NAME": db_name,
"HOST": "localhost",
# The following DB settings are only used for `postgresql` and `postgis`
"PORT": os.environ.get("POSTGRES_PORT", ""),
"USER": os.environ.get("POSTGRES_USER", ""),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", ""),
"PORT": os.environ.get("PGPORT", ""),
"USER": os.environ.get("PGUSER", ""),
"PASSWORD": os.environ.get("PGPASSWORD", ""),
},
# Extra DB used to test multi database support
EXTRA_DB: {
"ENGINE": db_engine,
"NAME": extra_db_name,
"HOST": "localhost",
"PORT": os.environ.get("POSTGRES_PORT", ""),
"USER": os.environ.get("POSTGRES_USER", ""),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", ""),
"PORT": os.environ.get("PGPORT", ""),
"USER": os.environ.get("PGUSER", ""),
"PASSWORD": os.environ.get("PGPASSWORD", ""),
},
},
INSTALLED_APPS=installed_apps,
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ python =
setenv =
PYTHONPATH={toxinidir}
postgresql: TEST_DB=postgis
postgresql: POSTGRES_USER=postgres
postgresql: POSTGRES_PASSWORD=postgres
postgresql: PGUSER=postgres
sqlite: TEST_DB=sqlite
sqlite: USE_TZ=True
deps =
Expand Down

0 comments on commit 640f2ee

Please sign in to comment.