44
55from commitizen import cli , cmd , git
66from commitizen .exceptions import (
7- BumpCommitFailedError ,
7+ BumpTagFailedError ,
88 CurrentVersionNotFoundError ,
99 DryRunExit ,
1010 ExpectedExit ,
@@ -71,6 +71,7 @@ def test_bump_command(mocker):
7171
7272@pytest .mark .usefixtures ("tmp_commitizen_project" )
7373def test_bump_on_git_with_hooks_no_verify_disabled (mocker ):
74+ """Bump commit without --no-verify"""
7475 cmd .run ("mkdir .git/hooks" )
7576 with open (".git/hooks/pre-commit" , "w" ) as f :
7677 f .write ("#!/usr/bin/env bash\n " 'echo "0.1.0"' )
@@ -82,10 +83,29 @@ def test_bump_on_git_with_hooks_no_verify_disabled(mocker):
8283 testargs = ["cz" , "bump" , "--yes" ]
8384 mocker .patch .object (sys , "argv" , testargs )
8485
85- with pytest .raises (BumpCommitFailedError ) as excinfo :
86- cli .main ()
86+ cli .main ()
87+
88+ tag_exists = git .tag_exist ("0.2.0" )
89+ assert tag_exists is True
90+
91+
92+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
93+ def test_bump_tag_exists_raises_exception (mocker ):
94+ cmd .run ("mkdir .git/hooks" )
95+ with open (".git/hooks/post-commit" , "w" ) as f :
96+ f .write ("#!/usr/bin/env bash\n " "exit 9" )
97+ cmd .run ("chmod +x .git/hooks/post-commit" )
98+
99+ # MINOR
100+ create_file_and_commit ("feat: new file" )
101+ git .tag ("0.2.0" )
87102
88- assert 'git.commit error: "0.1.0"' in str (excinfo .value )
103+ testargs = ["cz" , "bump" , "--yes" ]
104+ mocker .patch .object (sys , "argv" , testargs )
105+
106+ with pytest .raises (BumpTagFailedError ) as excinfo :
107+ cli .main ()
108+ assert "fatal: tag '0.2.0' already exists" in str (excinfo .value )
89109
90110
91111@pytest .mark .usefixtures ("tmp_commitizen_project" )
0 commit comments