feat: enhance database session management with commit and rollback; add user and deal API tests
Test / test (push) Successful in 14s

This commit is contained in:
k1nq
2025-11-28 11:35:27 +05:00
parent 0ab3bfbb34
commit 193fa73c78
6 changed files with 330 additions and 2 deletions
+6 -1
View File
@@ -14,4 +14,9 @@ AsyncSessionMaker = async_sessionmaker(bind=engine, expire_on_commit=False)
async def get_session() -> AsyncGenerator[AsyncSession, None]:
"""Yield an async database session for request scope."""
async with AsyncSessionMaker() as session:
yield session
try:
yield session
await session.commit()
except Exception: # pragma: no cover - defensive cleanup
await session.rollback()
raise