test pg workflow

This commit is contained in:
hay-kot 2021-05-01 12:18:49 -08:00
commit 2dd5e6f482
4 changed files with 26 additions and 7 deletions

View file

@ -15,6 +15,16 @@ jobs:
env:
PRODUCTION: false
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: mealie
POSTGRES_PASSWORD: mealie
POSTGRES_DB: mealie
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
steps:
#----------------------------------------------
# check-out repo and set-up python
@ -54,3 +64,11 @@ jobs:
- name: Run Test Suite
run: |
make test-all
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run Test Suite Postgres
env:
DB_ENGINE: postgres
run: |
make test-all

View file

@ -82,9 +82,9 @@ class AppDirectories:
app_dirs = AppDirectories(CWD, DATA_DIR)
def determine_sqlite_path(path=False) -> str:
def determine_sqlite_path(path=False, suffix=DB_VERSION) -> str:
global app_dirs
db_path = app_dirs.DATA_DIR.joinpath(f"mealie_{DB_VERSION}.db") # ! Temporary Until Alembic
db_path = app_dirs.DATA_DIR.joinpath(f"mealie_{suffix}.db") # ! Temporary Until Alembic
if path:
return db_path

View file

@ -31,7 +31,7 @@ def api_client():
yield TestClient(app)
DB_URL.unlink()
DB_URL.unlink(missing_ok=True)
@fixture(scope="session")

View file

@ -1,7 +1,8 @@
from mealie.core.config import app_dirs, settings
from mealie.core.config import determine_sqlite_path, settings
# Monkeypatch Database Testing
DB_URL = app_dirs.DATA_DIR.joinpath("test.db")
DB_URL = determine_sqlite_path(path=True, suffix="test")
DB_URL.unlink(missing_ok=True)
settings.DB_URL = "sqlite:///" + str(DB_URL.absolute())
if settings.DB_ENGINE != "postgres":
# Monkeypatch Database Testing
settings.DB_URL = determine_sqlite_path(path=False, suffix="test")