"""Pytest bootstrap: isolate the test suite from the development database.

Must be imported before any app module (pytest imports conftest.py first), so
app.models.user picks up the test DB path instead of the dev DB. Without this,
tests that seed/rotate the admin password (test_auth_and_quota) permanently
mutate the developer's sonicforge.db.
"""
import os
import tempfile

os.environ.setdefault(
    "SONICFORGE_DB_PATH",
    os.path.join(tempfile.gettempdir(), "sonicforge_test.db"),
)
# Cô lập storage khỏi app production (đang chạy root, ghi sf_scan_state.json
# vào storage thật → pytest gặp PermissionError khi file root-owned).
os.environ.setdefault(
    "SONICFORGE_STORAGE_DIR",
    os.path.join(tempfile.gettempdir(), "sonicforge_test_storage"),
)
