feat: implement MongoDB test database reset for clean test sessions
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m22s

This commit is contained in:
2026-07-31 17:47:06 -04:00
parent 4f9b01ce38
commit 59adf22d42
3 changed files with 41 additions and 29 deletions
+4 -3
View File
@@ -24,7 +24,8 @@ def set_test_db_env():
os.environ['MONGO_URI'] = 'mongomock'
os.environ['SECRET_KEY'] = TEST_SECRET_KEY
os.environ['REFRESH_TOKEN_EXPIRY_DAYS'] = str(TEST_REFRESH_TOKEN_EXPIRY_DAYS)
# Ensure indexes are created once for the test session. This is safe to
# call repeatedly because MongoDB treats index creation as idempotent.
from db.db import ensure_mongodb_indexes
# Drop the MongoDB test database once at the start of the session so every
# test begins from a clean slate. Indexes are recreated afterward.
from db.db import reset_mongo_db, ensure_mongodb_indexes
reset_mongo_db()
ensure_mongodb_indexes()