test_print_next_integrity.py python
45 lines 1.5 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
1 """Data integrity — ``ok next`` is read-only and idempotent (§ONS.12)."""
2
3 from __future__ import annotations
4
5 import hashlib
6 from pathlib import Path
7
8 from cli.kit_root import kit_root
9 from tests.support import FIXTURES, git_status_runner, run_cli, write_config
10
11
12 def _sha(path: Path) -> str:
13 return hashlib.sha256(path.read_bytes()).hexdigest()
14
15
16 def test_twice_identical_no_mutation(tmp_path: Path, capsys) -> None:
17 write_config(tmp_path, "config-git-only.yaml")
18 docs = tmp_path / "docs"
19 docs.mkdir(parents=True, exist_ok=True)
20 handover = docs / "OVERSEER-HANDOVER.md"
21 roadmap = docs / "ROADMAP.md"
22 handover.write_text(
23 (FIXTURES / "print-next-handover.md").read_text(encoding="utf-8"),
24 encoding="utf-8",
25 )
26 roadmap.write_text("# Roadmap\n", encoding="utf-8")
27 lock = tmp_path / ".overseer" / "version.lock"
28 lock.write_text("kit_version: 0.1.0\n", encoding="utf-8")
29
30 before = {
31 "handover": _sha(handover),
32 "roadmap": _sha(roadmap),
33 "lock": _sha(lock),
34 }
35 runner = git_status_runner()
36 code1 = run_cli(["next"], cwd=tmp_path, runner=runner, kit=kit_root())
37 out1 = capsys.readouterr().out
38 code2 = run_cli(["next"], cwd=tmp_path, runner=runner, kit=kit_root())
39 out2 = capsys.readouterr().out
40 assert code1 == 0
41 assert code2 == 0
42 assert out1 == out2
43 assert _sha(handover) == before["handover"]
44 assert _sha(roadmap) == before["roadmap"]
45 assert _sha(lock) == before["lock"]
File History 1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago