"""Test bootstrap — runs before any test module imports config.

Points the SQLite DB at a throwaway temp file and sets a known dev token, so
tests never touch the real _cache/douanier.db. Starts from a clean slate.
"""
import os
import sys
import tempfile
from pathlib import Path

_DB = Path(tempfile.gettempdir()) / "douanier_test.db"
os.environ["DOUANIER_DB"] = str(_DB)
os.environ.setdefault("DOUANIER_DEV_TOKEN", "test-secret")

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

# fresh DB each run (drop WAL/shm siblings too)
for p in (_DB, Path(str(_DB) + "-wal"), Path(str(_DB) + "-shm")):
    if p.exists():
        p.unlink()
