Skip to content

Commit

Permalink
Actually test against the postgress db in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jan 19, 2024
1 parent 7d5dd47 commit 183895c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Prepare postgres env
if: matrix.db == 'postgres'
run: |
sed < env-template -e 's/DATABASE_URL=.*$/DATABASE_URL=postgresql:\/\/pep:pep@localhost\/memberdb/' > .env
sed < env-template -e 's|DATABASE_URL=.*$|DATABASE_URL=postgresql://pep:pep@localhost/memberdb|' > .env
- name: "Perform migrations"
run: poetry run flask db upgrade
Expand All @@ -66,7 +66,9 @@ jobs:
grep 'No changes in schema detected.' migrate.log
- name: tests
run: poetry run python -m pytest --cov member_database --cov-report=xml
run: |
export USE_CONFIG_DB=1
poetry run python -m pytest --cov member_database --cov-report=xml
- uses: codecov/codecov-action@v1
if: matrix.db == 'postgres'
10 changes: 9 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import os

from member_database import (
init_authentication_database,
Expand All @@ -18,7 +19,14 @@ def app(db_path):

from member_database import create_app

TestingConfig.SQLALCHEMY_DATABASE_URI = f"sqlite:///{db_path}"
# in the CI, we rely on the normal configuration db
# to test vs sqlite and postgres
# locally we create a fresh temporary sqlite db database
if not os.getenv("USE_CONFIG_DB", "0") == "1":
print("Using tmp sqlite db")
TestingConfig.SQLALCHEMY_DATABASE_URI = f"sqlite:///{db_path}"
else:
print("Using configured database")
app = create_app(TestingConfig)
return app

Expand Down

0 comments on commit 183895c

Please sign in to comment.