Skip to content

Commit a3e1433

Browse files
committed
fix: clean up PostgreSQL data between tests and rename rollback test function
1 parent d1f9fc5 commit a3e1433

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

tests/api/endpoints/test_heroes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_delete_hero(session: Session, client_with_db: TestClient):
101101
assert hero_in_db is None
102102

103103

104-
def test_update_hero_rollback_on_error(
104+
def test_update_hero_rollback_on_commit_error(
105105
mocker, client_with_db: TestClient, session: Session
106106
):
107107
"""Test that updating a hero rolls back on commit error."""

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def session_fixture(request, monkeypatch) -> Session:
6262
with Session(engine) as session:
6363
yield session
6464

65+
# For Postgres, clean up all data between tests
66+
if db_type == "postgres":
67+
command.downgrade(config, "base")
68+
6569
# Clean up
6670
engine.dispose()
6771
if path:

0 commit comments

Comments
 (0)