Skip to content

Commit da131a4

Browse files
committed
test(commands/commit): test aborting commit when there is nothing to commit
commitizen-tools#45
1 parent c43d6d8 commit da131a4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/test_commands.py

+11
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ def test_commit_retry_works(mocker):
7272
assert not os.path.isfile(temp_file)
7373

7474

75+
def test_commit_when_nothing_to_commit(mocker):
76+
is_staging_clean_mock = mocker.patch("commitizen.git.is_staging_clean")
77+
is_staging_clean_mock.return_value = True
78+
79+
with pytest.raises(SystemExit) as err:
80+
commit_cmd = commands.Commit(config, {})
81+
commit_cmd()
82+
83+
assert err.value.code == commands.commit.NOTHING_TO_COMMIT
84+
85+
7586
def test_example():
7687
with mock.patch("commitizen.out.write") as write_mock:
7788
commands.Example(config)()

0 commit comments

Comments
 (0)