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
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m22s
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user