rebuild(stage-2): establish runtime and persistence foundations

This commit is contained in:
leefer
2026-07-30 01:02:04 +08:00
parent b3ba840d4e
commit d969d2c092
26 changed files with 865 additions and 33 deletions
+22
View File
@@ -0,0 +1,22 @@
import pytest
from tools.database import main
def test_status_uses_configured_data_directory(tmp_path, monkeypatch, capsys) -> None:
monkeypatch.setenv("APP_ENV", "test")
monkeypatch.setenv("APP_DATA_DIR", str(tmp_path))
monkeypatch.delenv("APP_DATABASE_PATH", raising=False)
assert main(["status"]) == 0
assert capsys.readouterr().out.strip() == "available=true schema_version=0"
assert (tmp_path / "xiaobai.db").exists()
def test_downgrade_requires_explicit_confirmation(tmp_path, monkeypatch) -> None:
monkeypatch.setenv("APP_ENV", "test")
monkeypatch.setenv("APP_DATA_DIR", str(tmp_path))
with pytest.raises(SystemExit, match="confirm-downgrade"):
main(["downgrade", "--target", "0"])