test_atomic_writes.py python
24 lines 734 B
Raw
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor ⚠ breaking 2 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:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor 2 days ago