Skip to content

Commit 5503c48

Browse files
schlotterLee-W
authored andcommitted
test(commit): test always_signoff config option
Signed-off-by: Christian Schlotter <christian.schlotter@zeiss.com>
1 parent 62b13bb commit 5503c48

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/commands/test_commit_command.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
from pytest_mock import MockFixture
5+
from unittest.mock import ANY
56

67
from commitizen import cmd, commands
78
from commitizen.cz.exceptions import CzException
@@ -172,6 +173,31 @@ def test_commit_command_with_signoff_option(config, mocker: MockFixture):
172173
success_mock = mocker.patch("commitizen.out.success")
173174

174175
commands.Commit(config, {"signoff": True})()
176+
177+
commit_mock.assert_called_once_with(ANY, "-s")
178+
success_mock.assert_called_once()
179+
180+
181+
@pytest.mark.usefixtures("staging_is_clean")
182+
def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture):
183+
prompt_mock = mocker.patch("questionary.prompt")
184+
prompt_mock.return_value = {
185+
"prefix": "feat",
186+
"subject": "user created",
187+
"scope": "",
188+
"is_breaking_change": False,
189+
"body": "",
190+
"footer": "",
191+
}
192+
193+
commit_mock = mocker.patch("commitizen.git.commit")
194+
commit_mock.return_value = cmd.Command("success", "", b"", b"", 0)
195+
success_mock = mocker.patch("commitizen.out.success")
196+
197+
config.settings["always_signoff"] = True
198+
commands.Commit(config, {})()
199+
200+
commit_mock.assert_called_once_with(ANY, "-s")
175201
success_mock.assert_called_once()
176202

177203

0 commit comments

Comments
 (0)