Skip to content

Commit be9163f

Browse files
Xiao75896453Lee-W
authored andcommitted
test(commands): test command cz commit with arg -a
1 parent 8847b2d commit be9163f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/commands/test_commit_command.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,24 @@ def test_commit_in_non_git_project(tmpdir, config):
255255
with tmpdir.as_cwd():
256256
with pytest.raises(NotAGitProjectError):
257257
commands.Commit(config, {})
258+
259+
260+
@pytest.mark.usefixtures("staging_is_clean")
261+
def test_commit_command_with_add_option(config, mocker: MockFixture):
262+
prompt_mock = mocker.patch("questionary.prompt")
263+
prompt_mock.return_value = {
264+
"prefix": "feat",
265+
"subject": "user created",
266+
"scope": "",
267+
"is_breaking_change": False,
268+
"body": "",
269+
"footer": "",
270+
}
271+
272+
commit_mock = mocker.patch("commitizen.git.commit")
273+
commit_mock.return_value = cmd.Command("success", "", b"", b"", 0)
274+
success_mock = mocker.patch("commitizen.out.success")
275+
add_mock = mocker.patch("commitizen.git.add")
276+
commands.Commit(config, {"add": True})()
277+
add_mock.assert_called()
278+
success_mock.assert_called_once()

0 commit comments

Comments
 (0)