test_sync.py python
52 lines 1.6 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
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
File History 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 53 days ago