from __future__ import annotations from stewardship.cli import main def test_validate_exit_codes(make_repo, negative_repo): good = make_repo("positive/infra-lxd") assert main(["validate", "--repo", str(good), "--output", "json"]) == 0 bad = negative_repo("secret-field") assert main(["validate", "--repo", str(bad), "--output", "json"]) == 1 def test_missing_repository_returns_exit_3(tmp_path): missing = tmp_path / "does-not-exist" assert main(["validate", "--repo", str(missing), "--output", "json"]) == 3 def test_context_strict_truncation_returns_exit_4(make_repo): repo = make_repo("positive/infra-lxd") code = main( [ "context", "--repo", str(repo), "--intent", "container.deploy", "--materialize", "--budget-bytes", "1", "--strict", "--output", "json", ] ) assert code == 4 def test_init_apply_without_hash_returns_exit_2(tmp_path): code = main(["init", "--repo", str(tmp_path), "--apply", "--output", "json"]) assert code == 2