Skip to content

Commit 049a194

Browse files
gpongelliLee-W
authored andcommitted
test: tests for signed tag and assert for annotated tags
1 parent e18b89c commit 049a194

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/commands/test_bump_command.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ def test_bump_minor_increment_annotated(commit_msg, mocker):
6666
cmd_res = cmd.run('git for-each-ref refs/tags --format "%(objecttype):%(refname)"')
6767
assert tag_exists is True and "tag:refs/tags/0.2.0\n" in cmd_res.out
6868

69+
_is_signed = git.is_signed_tag("0.2.0")
70+
assert _is_signed is False
71+
72+
73+
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
74+
@pytest.mark.usefixtures("tmp_commitizen_project")
75+
def test_bump_minor_increment_annotated(commit_msg, mocker):
76+
create_file_and_commit(commit_msg)
77+
testargs = ["cz", "bump", "--yes", "--signed-tag"]
78+
mocker.patch.object(sys, "argv", testargs)
79+
cli.main()
80+
tag_exists = git.tag_exist("0.2.0")
81+
cmd_res = cmd.run('git for-each-ref refs/tags --format "%(objecttype):%(refname)"')
82+
assert tag_exists is True and "tag:refs/tags/0.2.0\n" in cmd_res.out
83+
84+
_is_signed = git.is_signed_tag("0.2.0")
85+
assert _is_signed is True
86+
6987

7088
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
7189
def test_bump_minor_increment_annotated_config_file(
@@ -83,6 +101,29 @@ def test_bump_minor_increment_annotated_config_file(
83101
cmd_res = cmd.run('git for-each-ref refs/tags --format "%(objecttype):%(refname)"')
84102
assert tag_exists is True and "tag:refs/tags/0.2.0\n" in cmd_res.out
85103

104+
_is_signed = git.is_signed_tag("0.2.0")
105+
assert _is_signed is False
106+
107+
108+
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
109+
def test_bump_minor_increment_signed_config_file(
110+
commit_msg, mocker, tmp_commitizen_project
111+
):
112+
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
113+
tmp_commitizen_cfg_file.write(
114+
f"{tmp_commitizen_cfg_file.read()}\n" f"signed_tag = 1"
115+
)
116+
create_file_and_commit(commit_msg)
117+
testargs = ["cz", "bump", "--yes"]
118+
mocker.patch.object(sys, "argv", testargs)
119+
cli.main()
120+
tag_exists = git.tag_exist("0.2.0")
121+
cmd_res = cmd.run('git for-each-ref refs/tags --format "%(objecttype):%(refname)"')
122+
assert tag_exists is True and "tag:refs/tags/0.2.0\n" in cmd_res.out
123+
124+
_is_signed = git.is_signed_tag("0.2.0")
125+
assert _is_signed is True
126+
86127

87128
@pytest.mark.usefixtures("tmp_commitizen_project")
88129
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)