rebuild(stage-15): complete governance and handoff
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from backend.database import MIGRATIONS, Database, MigrationRunner
|
||||
from tools.database import main
|
||||
|
||||
|
||||
@@ -14,6 +15,19 @@ def test_status_uses_configured_data_directory(tmp_path, monkeypatch, capsys) ->
|
||||
assert (tmp_path / "xiaobai.db").exists()
|
||||
|
||||
|
||||
def test_status_reads_an_existing_schema_without_mutating_history(
|
||||
tmp_path, monkeypatch, capsys
|
||||
) -> None:
|
||||
database_path = tmp_path / "existing.db"
|
||||
MigrationRunner(Database(database_path)).upgrade(MIGRATIONS)
|
||||
monkeypatch.setenv("APP_ENV", "test")
|
||||
monkeypatch.setenv("APP_DATABASE_PATH", str(database_path))
|
||||
|
||||
assert main(["status"]) == 0
|
||||
|
||||
assert capsys.readouterr().out.strip() == "available=true schema_version=10"
|
||||
|
||||
|
||||
def test_downgrade_requires_explicit_confirmation(tmp_path, monkeypatch) -> None:
|
||||
monkeypatch.setenv("APP_ENV", "test")
|
||||
monkeypatch.setenv("APP_DATA_DIR", str(tmp_path))
|
||||
|
||||
Reference in New Issue
Block a user