From 13e2893d08e20a2d7998de2a22692f93b65a6340 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 25 Jul 2026 00:17:52 +0000 Subject: [PATCH] test: mock git config in signoff ignore-author test test_default_signoff_skips_ignored_author did not mock get_git_config_value. Since author resolution reads git config user.name first when validating a prospective message, the test failed whenever the developer had user.name configured locally (it only passed in environments where user.name was unset). Mock it to return an empty string so resolution deterministically falls back to the commit author. --- tests/engine_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/engine_test.py b/tests/engine_test.py index 9d97ce81..dd1eff97 100644 --- a/tests/engine_test.py +++ b/tests/engine_test.py @@ -821,9 +821,12 @@ def test_default_signoff_rejects_missing_signoff(self): result = validator.validate(context) assert result == ValidationResult.FAIL + @patch(GIT_CONFIG_VALUE) @patch("commit_check.engine.get_commit_info") @pytest.mark.benchmark - def test_default_signoff_skips_ignored_author(self, mock_get_commit_info): + def test_default_signoff_skips_ignored_author( + self, mock_get_commit_info, mock_get_git_config_value + ): """Signoff check is skipped when the author is in ignore_authors. A commit with no signoff would normally fail, but an ignored author @@ -831,6 +834,9 @@ def test_default_signoff_skips_ignored_author(self, mock_get_commit_info): commit check. """ mock_get_commit_info.return_value = "dependabot[bot]" + # Mock git config so author resolution falls back to the commit author + # instead of the developer's real local user.name. + mock_get_git_config_value.return_value = "" validator = SignoffValidator(self._default_signoff_rule()) config = {"commit": {"ignore_authors": ["dependabot[bot]"]}} context = ValidationContext(stdin_text="chore: bump dep", config=config)