test_sync.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
2 days 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
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
2 days ago