test_atomic_writes.py python
24 lines 734 B
Raw
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 4 days ago
1 """Data-integrity tests for atomic per-file writes."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 from tests.support import run_cli
8
9
10 def test_no_half_written_file_on_failure(tmp_path: Path) -> None:
11 run_cli(["init", "--regime", "git-only", "--non-interactive"], cwd=tmp_path)
12 target = tmp_path / "docs" / "OVERSEER-HANDOVER.md"
13 original = target.read_bytes()
14
15 from unittest.mock import patch
16
17 with patch("cli.atomic.os.replace", side_effect=OSError("boom")):
18 run_cli(
19 ["init", "--regime", "git-only", "--non-interactive", "--force"],
20 cwd=tmp_path,
21 )
22
23 assert not list(target.parent.glob(".*.overseer.tmp"))
24 assert target.read_bytes() == original
File History 1 commit
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 4 days ago