Skip to content

Commit 3000edc

Browse files
committed
Update README & Dispose database engines in test fixtures to prevent CI hangs.
1 parent db54c91 commit 3000edc

5 files changed

Lines changed: 23 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ This project includes a `render.yaml` Blueprint for one-click deployment.
483483
- Connect database to service
484484

485485
4. **Access Your Application**
486-
- URL: `https://your-app-name.onrender.com`
487-
- Health check: `https://your-app-name.onrender.com/health`
486+
- URL: `https://dev-interview-platform-25.onrender.com`
487+
- Health check: `https://dev-interview-platform-25.onrender.com/health`
488488

489489
#### Automatic Deployments (CI/CD)
490490

431 Bytes
Binary file not shown.

server/tests/conftest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest_asyncio
33
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
44
from sqlalchemy.orm import sessionmaker
5-
from app.database import Base, get_db
5+
from app.database import Base, get_db, engine as app_engine # Import app_engine
66
from app.main import app, fastapi_app
77
import asyncio
88
from fastapi.testclient import TestClient
@@ -37,6 +37,15 @@ async def test_db():
3737
await conn.run_sync(Base.metadata.drop_all)
3838

3939

40+
# --- Cleanup Fixture to prevent CI Hangs ---
41+
@pytest_asyncio.fixture(scope="function", autouse=True)
42+
async def cleanup_engines():
43+
yield
44+
# Dispose both engines after every test function to ensure clean loop shutdown
45+
await engine.dispose()
46+
await app_engine.dispose()
47+
48+
4049
# Override the dependency
4150
@pytest.fixture(autouse=True)
4251
def override_dependency(test_db):
@@ -60,7 +69,7 @@ async def server():
6069
import socket
6170
import os
6271
import sys
63-
import signal
72+
# import signal
6473
from httpx import AsyncClient
6574

6675
# Find a free port
Binary file not shown.

server/tests_integration/conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest_asyncio
33
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
44
from sqlalchemy.orm import sessionmaker
5-
from app.database import Base, get_db
5+
from app.database import Base, get_db, engine as app_engine # Import app_engine
66
from app.main import fastapi_app as app
77
import asyncio
88
from httpx import AsyncClient, ASGITransport
@@ -37,6 +37,15 @@ async def test_db():
3737
await conn.run_sync(Base.metadata.drop_all)
3838

3939

40+
# --- Cleanup Fixture ---
41+
@pytest_asyncio.fixture(scope="function", autouse=True)
42+
async def cleanup_engines():
43+
yield
44+
# Dispose both engines to close connection pools
45+
await engine.dispose()
46+
await app_engine.dispose()
47+
48+
4049
# Override the dependency
4150
@pytest_asyncio.fixture(autouse=True)
4251
async def override_dependency(test_db):

0 commit comments

Comments
 (0)