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 f74589f

Browse files
bearomorphismLee-W
authored andcommitted
test(commit): when nothing is added to commit
1 parent 3db7754 commit f74589f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎tests/commands/test_commit_command.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,34 @@ def test_commit_command_shows_description_when_use_help_option(
523523

524524
out, _ = capsys.readouterr()
525525
file_regression.check(out, extension=".txt")
526+
527+
528+
@pytest.mark.usefixtures("staging_is_clean")
529+
@pytest.mark.parametrize(
530+
"out", ["no changes added to commit", "nothing added to commit"]
531+
)
532+
def test_commit_when_nothing_added_to_commit(config, mocker: MockFixture, out):
533+
prompt_mock = mocker.patch("questionary.prompt")
534+
prompt_mock.return_value = {
535+
"prefix": "feat",
536+
"subject": "user created",
537+
"scope": "",
538+
"is_breaking_change": False,
539+
"body": "",
540+
"footer": "",
541+
}
542+
543+
commit_mock = mocker.patch("commitizen.git.commit")
544+
commit_mock.return_value = cmd.Command(
545+
out=out,
546+
err="",
547+
stdout=out.encode(),
548+
stderr=b"",
549+
return_code=0,
550+
)
551+
error_mock = mocker.patch("commitizen.out.error")
552+
553+
commands.Commit(config, {})()
554+
555+
commit_mock.assert_called_once()
556+
error_mock.assert_called_once_with(out)

0 commit comments

Comments
(0)

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