diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b71a6d1..eb7f488 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ permissions: on: # Run on every push to the 'main' branch push: - branches: [ "main", "30-create-tests-and-set-up-a-github-pipeline" ] + branches: [ "main", "33-frontend-looks-like-logged-in-even-after-token-expires" ] # Also run on every pull request that targets the 'main' branch pull_request: branches: [ "main" ] @@ -24,6 +24,33 @@ jobs: # Specifies the virtual machine to run the job on. 'ubuntu-latest' is a common and cost-effective choice. runs-on: ubuntu-latest + # 1) Start a MariaDB service container for tests + services: + mariadb: + image: mariadb:11.4 + env: + MARIADB_ROOT_PASSWORD: rootpw + MARIADB_DATABASE: group_project_test + MARIADB_USER: appuser + MARIADB_PASSWORD: apppass + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping -h 127.0.0.1 -u root -prootpw --silent" + --health-interval=5s + --health-timeout=2s + --health-retries=20 + + # 2) Expose DB connection settings to steps so your app picks them up + env: + MARIADB_HOST: 127.0.0.1 + MARIADB_PORT: "3306" + MARIADB_DB: group_project_test + MARIADB_USER: appuser + MARIADB_PASSWORD: apppass + # Optional: enable SQL echo logs in CI for debugging + # SQL_ECHO: "1" + # ----------------- # ----- Steps ----- # ----------------- @@ -41,14 +68,19 @@ jobs: with: python-version: '3.11' # Use the Python version that matches your project - # Step 3: Install project dependencies - # Runs shell commands to install the libraries listed in your requirements.txt. + # Step 3: Install project dependencies (from repo root) - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - - # Step 4: Run your tests! + + # Step 4: Apply DB migrations before running tests + - name: Run Alembic migrations + run: | + alembic upgrade head + working-directory: ./7project/backend + + # Step 5: Run your tests! # Executes the pytest command to run your test suite. - name: Run tests with pytest run: pytest diff --git a/7project/backend/tests/test_unit_user_service.py b/7project/backend/tests/test_unit_user_service.py index 7e89962..dedff0e 100644 --- a/7project/backend/tests/test_unit_user_service.py +++ b/7project/backend/tests/test_unit_user_service.py @@ -19,7 +19,7 @@ def test_get_oauth_provider_known_unknown(): def test_get_jwt_strategy_lifetime(): strategy = user_service.get_jwt_strategy() assert strategy is not None - # Basic smoke check: strategy has a lifetime set to 3600 + # Basic smoke check: strategy has a lifetime set to 604800 assert getattr(strategy, "lifetime_seconds", None) in (604800,)