Skip to content

Commit ae0362e

Browse files
authored
test: mock git config in signoff ignore-author test (#481)
1 parent bd890f1 commit ae0362e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎tests/engine_test.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,16 +821,22 @@ def test_default_signoff_rejects_missing_signoff(self):
821821
result = validator.validate(context)
822822
assert result == ValidationResult.FAIL
823823

824+
@patch(GIT_CONFIG_VALUE)
824825
@patch("commit_check.engine.get_commit_info")
825826
@pytest.mark.benchmark
826-
def test_default_signoff_skips_ignored_author(self, mock_get_commit_info):
827+
def test_default_signoff_skips_ignored_author(
828+
self, mock_get_commit_info, mock_get_git_config_value
829+
):
827830
"""Signoff check is skipped when the author is in ignore_authors.
828831
829832
A commit with no signoff would normally fail, but an ignored author
830833
(e.g. a bot) should bypass the signoff check just like every other
831834
commit check.
832835
"""
833836
mock_get_commit_info.return_value = "dependabot[bot]"
837+
# Mock git config so author resolution falls back to the commit author
838+
# instead of the developer's real local user.name.
839+
mock_get_git_config_value.return_value = ""
834840
validator = SignoffValidator(self._default_signoff_rule())
835841
config = {"commit": {"ignore_authors": ["dependabot[bot]"]}}
836842
context = ValidationContext(stdin_text="chore: bump dep", config=config)

0 commit comments

Comments
 (0)