|
Option C Tools
|
Functions | |
| subprocess.CompletedProcess | _git (Path repo, *str args) |
| test_invalid_commit_message_yields_exit_3 (temp_git_project, make_compliant_py) | |
| test_force_commit_bypasses_message_validation (temp_git_project, make_compliant_py) | |
| test_no_staged_files_yields_exit_4 (temp_git_project) | |
| test_protected_branch_block_yields_exit_1_with_advisory (temp_git_project, make_compliant_py) | |
| test_happy_path_returns_staged_files_and_profile (temp_git_project, make_compliant_py) | |
Purpose
-------
OI-527 regression coverage — :func:`oct.git.quality_gate.pre_commit_checks`
replaces the four sequential early-return blocks that previously lived
in ``git_commit_cmd`` with a single :class:`PreCommitResult` dataclass.
These tests pin the contract: the helper surfaces the same exit codes
(3 / 4 / 1) and the same advisory messages the CLI used to emit inline.
Responsibilities
----------------
- Invalid commit message → ``ok=False``, ``exit_code=3``.
- ``force_commit=True`` bypasses the commit-message check.
- No staged files → ``ok=False``, ``exit_code=4``.
- Protected-branch block → ``ok=False``, ``exit_code=1`` with advisory.
- Happy path → ``ok=True``, ``staged_files`` populated, exit_code 0.
Diagnostics
-----------
Domain: GIT-TESTS
Levels:
L2 — test lifecycle
L3 — assertion details
L4 — deep tracing
Contracts
---------
- Tests create a real git repository in ``tmp_path`` via subprocess;
no global git state is modified.
|
protected |
Definition at line 44 of file test_pre_commit_checks.py.
| tests_git.test_pre_commit_checks.test_force_commit_bypasses_message_validation | ( | temp_git_project, | |
| make_compliant_py ) |
| tests_git.test_pre_commit_checks.test_happy_path_returns_staged_files_and_profile | ( | temp_git_project, | |
| make_compliant_py ) |
| tests_git.test_pre_commit_checks.test_invalid_commit_message_yields_exit_3 | ( | temp_git_project, | |
| make_compliant_py ) |
| tests_git.test_pre_commit_checks.test_no_staged_files_yields_exit_4 | ( | temp_git_project | ) |
Definition at line 88 of file test_pre_commit_checks.py.
| tests_git.test_pre_commit_checks.test_protected_branch_block_yields_exit_1_with_advisory | ( | temp_git_project, | |
| make_compliant_py ) |