mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
fix(tests): fixed testing DB deployment v4
This commit is contained in:
15
.github/workflows/run-tests.yml
vendored
15
.github/workflows/run-tests.yml
vendored
@@ -9,7 +9,7 @@ permissions:
|
|||||||
on:
|
on:
|
||||||
# Run on every push to the 'main' branch
|
# Run on every push to the 'main' branch
|
||||||
push:
|
push:
|
||||||
branches: [ "main", "33-frontend-looks-like-logged-in-even-after-token-expires" ]
|
branches: [ "main" ]
|
||||||
# Also run on every pull request that targets the 'main' branch
|
# Also run on every pull request that targets the 'main' branch
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
@@ -30,9 +30,9 @@ jobs:
|
|||||||
MARIADB_DATABASE: group_project # Using the DB name your app expects
|
MARIADB_DATABASE: group_project # Using the DB name your app expects
|
||||||
MARIADB_USER: appuser
|
MARIADB_USER: appuser
|
||||||
MARIADB_PASSWORD: apppass
|
MARIADB_PASSWORD: apppass
|
||||||
# ADD THIS BLOCK BACK IN
|
ports:
|
||||||
# This forces the job to wait until the DB is
|
- 3306:3306
|
||||||
# actually responding before continuing.
|
# Healthcheck ensures the job only starts when DB is ready
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd="mysqladmin ping -h 127.0.0.1 -u root -prootpw --silent"
|
--health-cmd="mysqladmin ping -h 127.0.0.1 -u root -prootpw --silent"
|
||||||
--health-interval=5s
|
--health-interval=5s
|
||||||
@@ -40,9 +40,9 @@ jobs:
|
|||||||
--health-retries=20
|
--health-retries=20
|
||||||
|
|
||||||
# This is the job-level 'env' block
|
# This is the job-level 'env' block
|
||||||
# It will be used by the 'alembic' step
|
# It will be used by all steps (alembic, pytest, etc.)
|
||||||
env:
|
env:
|
||||||
MARIADB_HOST: mariadb # Use the service label as the host
|
MARIADB_HOST: 127.0.0.1
|
||||||
MARIADB_PORT: "3306"
|
MARIADB_PORT: "3306"
|
||||||
MARIADB_DB: group_project
|
MARIADB_DB: group_project
|
||||||
MARIADB_USER: appuser
|
MARIADB_USER: appuser
|
||||||
@@ -73,7 +73,8 @@ jobs:
|
|||||||
# file that your pytest setup might be loading
|
# file that your pytest setup might be loading
|
||||||
- name: Run tests with pytest
|
- name: Run tests with pytest
|
||||||
env:
|
env:
|
||||||
MARIADB_HOST: mariadb
|
MARIADB_HOST: 127.0.0.1
|
||||||
|
MARIADB_PORT: "3306"
|
||||||
MARIADB_DB: group_project
|
MARIADB_DB: group_project
|
||||||
MARIADB_USER: appuser
|
MARIADB_USER: appuser
|
||||||
MARIADB_PASSWORD: apppass
|
MARIADB_PASSWORD: apppass
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ if not DATABASE_URL:
|
|||||||
|
|
||||||
SYNC_DATABASE_URL = DATABASE_URL.replace("+asyncmy", "+pymysql")
|
SYNC_DATABASE_URL = DATABASE_URL.replace("+asyncmy", "+pymysql")
|
||||||
|
|
||||||
ssl_enabled = os.getenv("MARIADB_HOST", "localhost") != "localhost"
|
host_env = os.getenv("MARIADB_HOST", "localhost")
|
||||||
|
ssl_enabled = host_env not in {"localhost", "127.0.0.1"}
|
||||||
connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {}
|
connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {}
|
||||||
|
|
||||||
def run_migrations_offline() -> None:
|
def run_migrations_offline() -> None:
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ from app.models.user import User
|
|||||||
from app.models.transaction import Transaction
|
from app.models.transaction import Transaction
|
||||||
from app.models.categories import Category
|
from app.models.categories import Category
|
||||||
|
|
||||||
ssl_enabled = os.getenv("MARIADB_HOST", "localhost") != "localhost"
|
host_env = os.getenv("MARIADB_HOST", "localhost")
|
||||||
|
ssl_enabled = host_env not in {"localhost", "127.0.0.1"}
|
||||||
connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {}
|
connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {}
|
||||||
|
|
||||||
engine = create_async_engine(
|
engine = create_async_engine(
|
||||||
|
|||||||
Reference in New Issue
Block a user