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 cd93206

Browse files
committed
test(commit): add negative test cases for --write-message-to-file option
1 parent dc0c86f commit cd93206

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎tests/commands/test_commit_command.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
NoAnswersError,
1313
NoCommitBackupError,
1414
NotAGitProjectError,
15+
NotAllowed,
1516
NothingToCommitError,
1617
)
1718

@@ -135,6 +136,27 @@ def test_commit_command_with_write_message_to_file_option(
135136
assert tmp_file.read_text() == "feat: user created"
136137

137138

139+
@pytest.mark.usefixtures("staging_is_clean")
140+
@pytest.mark.parametrize("message_file", [True, False, 0, 1])
141+
def test_commit_command_with_invalid_write_message_to_file_option(
142+
config, message_file, mocker: MockFixture
143+
):
144+
prompt_mock = mocker.patch("questionary.prompt")
145+
prompt_mock.return_value = {
146+
"prefix": "feat",
147+
"subject": "user created",
148+
"scope": "",
149+
"is_breaking_change": False,
150+
"body": "",
151+
"footer": "",
152+
}
153+
154+
with pytest.raises(NotAllowed):
155+
print(isinstance(message_file, str))
156+
commit_cmd = commands.Commit(config, {"write_message_to_file": message_file})
157+
commit_cmd()
158+
159+
138160
@pytest.mark.usefixtures("staging_is_clean")
139161
def test_commit_command_with_signoff_option(config, mocker: MockFixture):
140162
prompt_mock = mocker.patch("questionary.prompt")

0 commit comments

Comments
(0)

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