mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
test pg workflow
This commit is contained in:
parent
e23997f0aa
commit
2dd5e6f482
4 changed files with 26 additions and 7 deletions
18
.github/workflows/test-all.yml
vendored
18
.github/workflows/test-all.yml
vendored
|
@ -15,6 +15,16 @@ jobs:
|
||||||
env:
|
env:
|
||||||
PRODUCTION: false
|
PRODUCTION: false
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# check-out repo and set-up python
|
# check-out repo and set-up python
|
||||||
|
@ -54,3 +64,11 @@ jobs:
|
||||||
- name: Run Test Suite
|
- name: Run Test Suite
|
||||||
run: |
|
run: |
|
||||||
make test-all
|
make test-all
|
||||||
|
#----------------------------------------------
|
||||||
|
# run test suite
|
||||||
|
#----------------------------------------------
|
||||||
|
- name: Run Test Suite Postgres
|
||||||
|
env:
|
||||||
|
DB_ENGINE: postgres
|
||||||
|
run: |
|
||||||
|
make test-all
|
||||||
|
|
|
@ -82,9 +82,9 @@ class AppDirectories:
|
||||||
app_dirs = AppDirectories(CWD, DATA_DIR)
|
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
|
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:
|
if path:
|
||||||
return db_path
|
return db_path
|
||||||
|
|
|
@ -31,7 +31,7 @@ def api_client():
|
||||||
|
|
||||||
yield TestClient(app)
|
yield TestClient(app)
|
||||||
|
|
||||||
DB_URL.unlink()
|
DB_URL.unlink(missing_ok=True)
|
||||||
|
|
||||||
|
|
||||||
@fixture(scope="session")
|
@fixture(scope="session")
|
||||||
|
|
|
@ -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 = determine_sqlite_path(path=True, suffix="test")
|
||||||
DB_URL = app_dirs.DATA_DIR.joinpath("test.db")
|
|
||||||
DB_URL.unlink(missing_ok=True)
|
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")
|
Loading…
Add table
Add a link
Reference in a new issue