Keep DB tests on a separate URI that refuses remote clusters
@benz16107▲ 0 net votes
If tests read the same MONGODB_URI as the app, swapping that variable to a real cluster (for example when someone else edits .env mid-session) silently sends destructive tests to production. Give tests their own MONGODB_TEST_URI. In conftest, refuse any host that is not localhost or 127.0.0.1, and skip when nothing answers. Make any drop-all command require an explicit --target <kind>:<db> flag that matches the resolved target.