test_init.py python
91 lines 2.8 KB
Raw
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 54 days ago
1 """Unit tests for ``overseer init``."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 import pytest
8
9 from cli.kit_root import kit_root
10 from cli.version_lock import read_version_lock
11 from tests.support import FIXTURES, run_cli
12
13
14 def test_init_creates_footprint_and_lock(tmp_path: Path) -> None:
15 code = run_cli(
16 ["init", "--regime", "git-only", "--repo-name", "demo", "--non-interactive"],
17 cwd=tmp_path,
18 )
19 assert code == 0
20 assert (tmp_path / ".overseer" / "config.yaml").is_file()
21 assert (tmp_path / ".overseer" / "version.lock").is_file()
22 assert (tmp_path / ".overseer" / "STANDING-DECISIONS.reference.md").is_file()
23 lock = read_version_lock(tmp_path / ".overseer" / "version.lock")
24 assert lock.kit_version == "0.1.0"
25
26
27 def test_init_missing_regime_non_interactive_fails_closed(tmp_path: Path) -> None:
28 code = run_cli(["init", "--non-interactive"], cwd=tmp_path)
29 assert code == 2
30
31
32 def test_init_refuse_without_force(tmp_path: Path) -> None:
33 run_cli(
34 ["init", "--regime", "git-only", "--non-interactive"],
35 cwd=tmp_path,
36 )
37 (tmp_path / "docs" / "OVERSEER-HANDOVER.md").write_text("hand edit\n", encoding="utf-8")
38 code = run_cli(["init", "--regime", "git-only", "--non-interactive"], cwd=tmp_path)
39 assert code == 4
40
41
42 def test_init_force_reinits(tmp_path: Path) -> None:
43 run_cli(
44 ["init", "--regime", "git-only", "--non-interactive"],
45 cwd=tmp_path,
46 )
47 (tmp_path / "docs" / "OVERSEER-HANDOVER.md").write_text("hand edit\n", encoding="utf-8")
48 code = run_cli(
49 ["init", "--regime", "git-only", "--non-interactive", "--force"],
50 cwd=tmp_path,
51 )
52 assert code == 0
53 assert "hand edit" not in (tmp_path / "docs" / "OVERSEER-HANDOVER.md").read_text(encoding="utf-8")
54
55
56 def test_init_noop_when_current(tmp_path: Path) -> None:
57 run_cli(
58 ["init", "--regime", "git-only", "--non-interactive"],
59 cwd=tmp_path,
60 )
61 lock_path = tmp_path / ".overseer" / "version.lock"
62 before = lock_path.read_text(encoding="utf-8")
63 code = run_cli(
64 ["init", "--regime", "git-only", "--non-interactive"],
65 cwd=tmp_path,
66 )
67 assert code == 0
68 assert lock_path.read_text(encoding="utf-8") == before
69
70
71 def test_init_from_config(tmp_path: Path) -> None:
72 code = run_cli(
73 [
74 "init",
75 "--from-config",
76 str(FIXTURES / "config-git-only.yaml"),
77 "--non-interactive",
78 ],
79 cwd=tmp_path,
80 kit=kit_root(),
81 )
82 assert code == 0
83
84
85 def test_init_dry_run_writes_nothing(tmp_path: Path) -> None:
86 code = run_cli(
87 ["init", "--regime", "git-only", "--non-interactive", "--dry-run"],
88 cwd=tmp_path,
89 )
90 assert code == 0
91 assert not (tmp_path / ".overseer" / "version.lock").exists()
File History 1 commit
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 54 days ago