Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit af8e276

Browse files
committed
test(commit): add test for --write-message-to-file option
1 parent ff56b4e commit af8e276

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
@@ -109,6 +109,32 @@ def test_commit_command_with_dry_run_option(config, mocker: MockFixture):
109109
commit_cmd()
110110

111111

112+
@pytest.mark.usefixtures("staging_is_clean")
113+
def test_commit_command_with_write_message_to_file_option(
114+
config, tmp_path, mocker: MockFixture
115+
):
116+
tmp_file = tmp_path / "message"
117+
118+
prompt_mock = mocker.patch("questionary.prompt")
119+
prompt_mock.return_value = {
120+
"prefix": "feat",
121+
"subject": "user created",
122+
"scope": "",
123+
"is_breaking_change": False,
124+
"body": "",
125+
"footer": "",
126+
}
127+
128+
commit_mock = mocker.patch("commitizen.git.commit")
129+
commit_mock.return_value = cmd.Command("success", "", b"", b"", 0)
130+
success_mock = mocker.patch("commitizen.out.success")
131+
132+
commands.Commit(config, {"write_message_to_file": str(tmp_file)})()
133+
success_mock.assert_called_once()
134+
assert tmp_file.exists()
135+
assert tmp_file.read_text() == "feat: user created"
136+
137+
112138
@pytest.mark.usefixtures("staging_is_clean")
113139
def test_commit_command_with_signoff_option(config, mocker: MockFixture):
114140
prompt_mock = mocker.patch("questionary.prompt")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /