test(backup): assert the integrity-failure message on corrupt import
f55f937cee made run_import tell the user when an archived database fails its integrity check instead of blaming a live holder, but nothing asserted that message: reverting its prod hunk left the suite green. Extend the existing corrupt-source test to require "failed its integrity check" in the import output, so the misleading holder message cannot come back. Verified: 24 pass on head; 9 fail with f55f937cee's prod hunk reverted.
This commit is contained in:
@@ -83,7 +83,9 @@ def test_restore_uses_literal_paths_and_preserves_live_connection(
|
||||
|
||||
@pytest.mark.parametrize("entry", ["snapshot", "import"])
|
||||
@pytest.mark.parametrize("damage", ["header", "btree", "truncated"])
|
||||
def test_corrupt_source_cannot_replace_a_healthy_database(tmp_path, home, entry, damage):
|
||||
def test_corrupt_source_cannot_replace_a_healthy_database(
|
||||
tmp_path, capsys, home, entry, damage
|
||||
):
|
||||
live = home / "state.db"
|
||||
with closing(sqlite3.connect(live)) as db:
|
||||
db.execute("CREATE TABLE evidence(value TEXT)")
|
||||
@@ -113,6 +115,9 @@ def test_corrupt_source_cannot_replace_a_healthy_database(tmp_path, home, entry,
|
||||
inode = live.stat().st_ino
|
||||
|
||||
assert not _restore(entry, home, snapshot_id, source)
|
||||
if entry == "import":
|
||||
captured = capsys.readouterr()
|
||||
assert "failed its integrity check" in captured.out + captured.err
|
||||
|
||||
assert live.read_bytes() == before
|
||||
assert live.stat().st_ino == inode
|
||||
|
||||
Reference in New Issue
Block a user