8000 Merge pull request #257 from josix/update/bump_test · AnarchyCrew/commitizen@6efb23f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6efb23f

Browse files
authored
Merge pull request commitizen-tools#257 from josix/update/bump_test
Update bump test cases to add more different message pattern
2 parents b207e6d + b26f408 commit 6efb23f

File tree

1 file changed

+48
-23
lines changed

1 file changed

+48
-23
lines changed

tests/commands/test_bump_command.py

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,81 @@
1616
from tests.utils import create_file_and_commit
1717

1818

19+
@pytest.mark.parametrize(
20+
"commit_msg",
21+
(
22+
"fix: username exception",
23+
"fix(user): username exception",
24+
"refactor: remove ini configuration support",
25+
"refactor(config): remove ini configuration support",
26+
"perf: update to use multiproess",
27+
"perf(worker): update to use multiproess",
28+
),
29+
)
1930
@pytest.mark.usefixtures("tmp_commitizen_project")
20-
def test_bump_command(mocker):
21-
# MINOR
22-
create_file_and_commit("feat: new file")
23-
31+
def test_bump_patch_increment(commit_msg, mocker):
32+
create_file_and_commit(commit_msg)
2433
testargs = ["cz", "bump", "--yes"]
2534
mocker.patch.object(sys, "argv", testargs)
2635
cli.main()
36+
tag_exists = git.tag_exist("0.1.1")
37+
assert tag_exists is True
38+
2739

40+
@pytest.mark.parametrize("commit_msg", ("feat: new file", "feat(user): new file"))
41+
@pytest.mark.usefixtures("tmp_commitizen_project")
42+
def test_bump_minor_increment(commit_msg, mocker):
43+
create_file_and_commit(commit_msg)
44+
testargs = ["cz", "bump", "--yes"]
45+
mocker.patch.object(sys, "argv", testargs)
46+
cli.main()
2847
tag_exists = git.tag_exist("0.2.0")
2948
assert tag_exists is True
3049

31-
# PATCH
32-
create_file_and_commit("fix: username exception")
3350

34-
testargs = ["cz", "bump"]
51+
@pytest.mark.usefixtures("tmp_commitizen_project")
52+
@pytest.mark.parametrize(
53+
"commit_msg",
54+
(
55+
"feat: new user interface\n\nBREAKING CHANGE: age is no longer supported",
56+
"feat!: new user interface\n\nBREAKING CHANGE: age is no longer supported",
57+
"feat!: new user interface",
58+
"feat(user): new user interface\n\nBREAKING CHANGE: age is no longer supported",
59+
"feat(user)!: new user interface\n\nBREAKING CHANGE: age is no longer supported",
60+
"feat(user)!: new user interface",
61+
"BREAKING CHANGE: age is no longer supported",
62+
"BREAKING-CHANGE: age is no longer supported",
63+
),
64+
)
65+
def test_bump_major_increment(commit_msg, mocker):
66+
create_file_and_commit(commit_msg)
67+
68+
testargs = ["cz", "bump", "--yes"]
3569
mocker.patch.object(sys, "argv", testargs)
3670
cli.main()
3771

38-
tag_exists = git.tag_exist("0.2.1")
72+
tag_exists = git.tag_exist("1.0.0")
3973
assert tag_exists is True
4074

75+
76+
@pytest.mark.usefixtures("tmp_commitizen_project")
77+
def test_bump_command_prelease(mocker):
4178
# PRERELEASE
4279
create_file_and_commit("feat: location")
4380

44-
testargs = ["cz", "bump", "--prerelease", "alpha"]
81+
testargs = ["cz", "bump", "--prerelease", "alpha", "--yes"]
4582
mocker.patch.object(sys, "argv", testargs)
4683
cli.main()
4784

48-
tag_exists = git.tag_exist("0.3.0a0")
85+
tag_exists = git.tag_exist("0.2.0a0")
4986
assert tag_exists is True
5087

5188
# PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
5289
testargs = ["cz", "bump"]
5390
mocker.patch.object(sys, "argv", testargs)
5491
cli.main()
5592

56-
tag_exists = git.tag_exist("0.3.0")
57-
assert tag_exists is True
58-
59-
# MAJOR
60-
create_file_and_commit(
61-
"feat: new user interface\n\nBREAKING CHANGE: age is no longer supported"
62-
)
63-
64-
testargs = ["cz", "bump"]
65-
mocker.patch.object(sys, "argv", testargs)
66-
cli.main()
67-
68-
tag_exists = git.tag_exist("1.0.0")
93+
tag_exists = git.tag_exist("0.2.0")
6994
assert tag_exists is True
7095

7196

0 commit comments

Comments
 (0)
0