test_atomic_writes.py file-level

at main · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
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