"""CLI honors GOODNEWS_DB for its default --db, matching db.connect. Without this, a
copy-DB maintenance run (e.g. `dedup --force-recluster`) silently targets production."""
from pathlib import Path

from goodnews.cli import DEFAULT_DB, _default_db


def test_default_db_honors_env(monkeypatch):
    monkeypatch.setenv("GOODNEWS_DB", "/tmp/some-copy.sqlite3")
    assert _default_db() == Path("/tmp/some-copy.sqlite3")


def test_default_db_falls_back_to_bundled(monkeypatch):
    monkeypatch.delenv("GOODNEWS_DB", raising=False)
    assert _default_db() == DEFAULT_DB
