4
4
5
5
from commitizen import cli , cmd , git
6
6
from commitizen .exceptions import (
7
- BumpCommitFailedError ,
7
+ BumpTagFailedError ,
8
8
CurrentVersionNotFoundError ,
9
9
DryRunExit ,
10
10
ExpectedExit ,
@@ -71,6 +71,7 @@ def test_bump_command(mocker):
71
71
72
72
@pytest .mark .usefixtures ("tmp_commitizen_project" )
73
73
def test_bump_on_git_with_hooks_no_verify_disabled (mocker ):
74
+ """Bump commit without --no-verify"""
74
75
cmd .run ("mkdir .git/hooks" )
75
76
with open (".git/hooks/pre-commit" , "w" ) as f :
76
77
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):
82
83
testargs = ["cz" , "bump" , "--yes" ]
83
84
mocker .patch .object (sys , "argv" , testargs )
84
85
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" )
87
102
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 )
89
109
90
110
91
111
@pytest .mark .usefixtures ("tmp_commitizen_project" )
0 commit comments