feat: enhance test data cleanup by dropping MongoDB test database if applicable
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m22s

This commit is contained in:
2026-07-31 16:23:15 -04:00
parent 0b89833c32
commit d69d2226a3
+7 -1
View File
@@ -579,8 +579,14 @@ def ensure_mongodb_indexes(client=None, db_name=None):
coll.create_index(keys, **kwargs)
# Clear test collections at import time so tests start with a clean slate.
# Clear test data at import time so tests start with a clean slate.
if os.environ.get('DB_ENV', 'prod') == 'test':
if USE_MONGODB:
# Drop the entire MongoDB test database for a fresh start. Only do this
# for clearly test/e2e database names as a safety guard.
if _mongo_db_name and _mongo_db_name.endswith(('_test', '_e2e')):
get_mongo_client().drop_database(_mongo_db_name)
else:
child_db.truncate()
task_db.truncate()
routine_db.truncate()