repo-manager/tests/test_scaffold.py
tegwick a6d4a9b615 feat: flavor-correct rmgr scaffold; record C-15/C-23 file-wins
RMGR-WP-0004-T03: project repos get GOAL.md and a required prefix.
RMGR-WP-0005-T06 implemented in state-hub consistency.
2026-08-18 13:36:26 +02:00

65 lines
2.1 KiB
Python

from pathlib import Path
from repo_manager.cli import main
from repo_manager.commands.scaffold import scaffold_repository
from repo_manager.standards import check_repository
def test_prj_scaffold_requires_prefix(tmp_path: Path):
dest = tmp_path / "prj-example"
result = scaffold_repository(dest, flavor="project", commit=False)
assert result.status == "rejected"
assert "wp-prefix" in (result.error or {}).get("message", "").lower() or "PRJ" in str(
result.error
)
def test_prj_scaffold_refuses_flavor_prefix(tmp_path: Path):
dest = tmp_path / "prj-example"
result = scaffold_repository(dest, flavor="project", wp_prefix="PRJ-WP", commit=False)
assert result.status == "rejected"
def test_prj_scaffold_writes_goal_not_intent(tmp_path: Path):
dest = tmp_path / "prj-example-cutover"
result = scaffold_repository(
dest, flavor="project", wp_prefix="EXCO-WP", commit=False
)
assert result.status == "applied"
assert (dest / "GOAL.md").is_file()
assert not (dest / "INTENT.md").exists()
goal = (dest / "GOAL.md").read_text()
for heading in ("Outcome", "Invariants", "Success gates", "Project retirement"):
assert heading in goal
assert not list((dest / "workplans").glob("*-0001-*.md"))
report = check_repository(dest)
assert report.ok, report.to_dict()
def test_durable_scaffold_writes_intent(tmp_path: Path):
dest = tmp_path / "some-tool"
result = scaffold_repository(dest, flavor="tooling", commit=False)
assert result.status == "applied"
assert (dest / "INTENT.md").is_file()
assert not (dest / "GOAL.md").exists()
assert (dest / "workplans" / "SOMETOOL-WP-0001-foundation.md").is_file()
report = check_repository(dest)
assert report.ok, report.to_dict()
def test_cli_scaffold(tmp_path: Path):
dest = tmp_path / "cli-tool"
assert (
main(
[
"scaffold",
"--path",
str(dest),
"--flavor",
"tooling",
"--no-commit",
]
)
== 0
)
assert (dest / "INTENT.md").is_file()