Skip to content

Commit

Permalink
test(commit): test always_signoff config option
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Schlotter <[email protected]>
  • Loading branch information
schlotter authored and Lee-W committed Sep 5, 2023
1 parent 62b13bb commit 5503c48
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/commands/test_commit_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from pytest_mock import MockFixture
from unittest.mock import ANY

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

commands.Commit(config, {"signoff": True})()

commit_mock.assert_called_once_with(ANY, "-s")
success_mock.assert_called_once()


@pytest.mark.usefixtures("staging_is_clean")
def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture):
prompt_mock = mocker.patch("questionary.prompt")
prompt_mock.return_value = {
"prefix": "feat",
"subject": "user created",
"scope": "",
"is_breaking_change": False,
"body": "",
"footer": "",
}

commit_mock = mocker.patch("commitizen.git.commit")
commit_mock.return_value = cmd.Command("success", "", b"", b"", 0)
success_mock = mocker.patch("commitizen.out.success")

config.settings["always_signoff"] = True
commands.Commit(config, {})()

commit_mock.assert_called_once_with(ANY, "-s")
success_mock.assert_called_once()


Expand Down

0 comments on commit 5503c48

Please sign in to comment.