Option C Tools
Loading...
Searching...
No Matches
tests_git.test_pre_commit_checks Namespace Reference

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)

Detailed Description

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.

Function Documentation

◆ _git()

subprocess.CompletedProcess tests_git.test_pre_commit_checks._git ( Path repo,
*str args )
protected

Definition at line 44 of file test_pre_commit_checks.py.

Here is the caller graph for this function:

◆ test_force_commit_bypasses_message_validation()

tests_git.test_pre_commit_checks.test_force_commit_bypasses_message_validation ( temp_git_project,
make_compliant_py )

Definition at line 70 of file test_pre_commit_checks.py.

Here is the call graph for this function:

◆ test_happy_path_returns_staged_files_and_profile()

tests_git.test_pre_commit_checks.test_happy_path_returns_staged_files_and_profile ( temp_git_project,
make_compliant_py )

Definition at line 131 of file test_pre_commit_checks.py.

Here is the call graph for this function:

◆ test_invalid_commit_message_yields_exit_3()

tests_git.test_pre_commit_checks.test_invalid_commit_message_yields_exit_3 ( temp_git_project,
make_compliant_py )

Definition at line 50 of file test_pre_commit_checks.py.

Here is the call graph for this function:

◆ test_no_staged_files_yields_exit_4()

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.

◆ test_protected_branch_block_yields_exit_1_with_advisory()

tests_git.test_pre_commit_checks.test_protected_branch_block_yields_exit_1_with_advisory ( temp_git_project,
make_compliant_py )

Definition at line 103 of file test_pre_commit_checks.py.

Here is the call graph for this function: