← Back to list challenge
Test Database Safety - Guard Before RefreshDatabase
TestCase guard validates APP_ENV and DB_DATABASE before RefreshDatabase wipes the DB.
Problem
RefreshDatabase could wipe the dev DB if env is wrong.
Decision
Guard in TestCase::setUp, validate APP_ENV and DB prefix before init.
Result
Fail-fast on bad config; dev DB never wiped.
Implementation
- Guard fails fast before RefreshDatabase touches the DB.
- The db_stockflow_test* naming convention provides a second safety layer.