test_sync.py file-level

at main · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:8 docs: queue board-identity follow-ups so they survive the session Capt… · aaronrene · Sep 5, 2026
1 """Unit tests for ``overseer sync``."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 from cli.version_lock import read_version_lock
8 from tests.support import run_cli
9
10
11 def _init(tmp_path: Path) -> None:
12 run_cli(
13 ["init", "--regime", "git-only", "--non-interactive"],
14 cwd=tmp_path,
15 )
16
17
18 def test_sync_noop_at_same_version(tmp_path: Path) -> None:
19 _init(tmp_path)
20 code = run_cli(["sync", "-y"], cwd=tmp_path)
21 assert code == 0
22
23
24 def test_sync_refuse_consumer_modified(tmp_path: Path) -> None:
25 _init(tmp_path)
26 handover = tmp_path / "docs" / "OVERSEER-HANDOVER.md"
27 handover.write_text(handover.read_text(encoding="utf-8") + "\n# edited\n", encoding="utf-8")
28 code = run_cli(["sync", "-y"], cwd=tmp_path)
29 assert code == 4
30
31
32 def test_sync_force_applies(tmp_path: Path) -> None:
33 _init(tmp_path)
34 handover = tmp_path / "docs" / "OVERSEER-HANDOVER.md"
35 handover.write_text("consumer edit\n", encoding="utf-8")
36 code = run_cli(["sync", "-y", "--force"], cwd=tmp_path)
37 assert code == 0
38 assert "consumer edit" not in handover.read_text(encoding="utf-8")
39
40
41 def test_sync_dry_run_writes_nothing(tmp_path: Path) -> None:
42 _init(tmp_path)
43 lock_before = read_version_lock(tmp_path / ".overseer" / "version.lock").synced_at
44 code = run_cli(["sync", "--dry-run", "-y"], cwd=tmp_path)
45 assert code == 0
46 lock_after = read_version_lock(tmp_path / ".overseer" / "version.lock").synced_at
47 assert lock_before == lock_after
48
49
50 def test_sync_missing_config_fails_closed(tmp_path: Path) -> None:
51 code = run_cli(["sync", "-y"], cwd=tmp_path)
52 assert code == 2