|
16 | 16 | from tests.utils import create_file_and_commit
|
17 | 17 |
|
18 | 18 |
|
| 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 | +) |
19 | 30 | @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) |
24 | 33 | testargs = ["cz", "bump", "--yes"]
|
25 | 34 | mocker.patch.object(sys, "argv", testargs)
|
26 | 35 | cli.main()
|
| 36 | + tag_exists = git.tag_exist("0.1.1") |
| 37 | + assert tag_exists is True |
| 38 | + |
27 | 39 |
|
| 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() |
28 | 47 | tag_exists = git.tag_exist("0.2.0")
|
29 | 48 | assert tag_exists is True
|
30 | 49 |
|
31 |
| - # PATCH |
32 |
| - create_file_and_commit("fix: username exception") |
33 | 50 |
|
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"] |
35 | 69 | mocker.patch.object(sys, "argv", testargs)
|
36 | 70 | cli.main()
|
37 | 71 |
|
38 |
| - tag_exists = git.tag_exist("0.2.1") |
| 72 | + tag_exists = git.tag_exist("1.0.0") |
39 | 73 | assert tag_exists is True
|
40 | 74 |
|
| 75 | + |
| 76 | +@pytest.mark.usefixtures("tmp_commitizen_project") |
| 77 | +def test_bump_command_prelease(mocker): |
41 | 78 | # PRERELEASE
|
42 | 79 | create_file_and_commit("feat: location")
|
43 | 80 |
|
44 |
| - testargs = ["cz", "bump", "--prerelease", "alpha"] |
| 81 | + testargs = ["cz", "bump", "--prerelease", "alpha", "--yes"] |
45 | 82 | mocker.patch.object(sys, "argv", testargs)
|
46 | 83 | cli.main()
|
47 | 84 |
|
48 |
| - tag_exists = git.tag_exist("0.3.0a0") |
| 85 | + tag_exists = git.tag_exist("0.2.0a0") |
49 | 86 | assert tag_exists is True
|
50 | 87 |
|
51 | 88 | # PRERELEASE BUMP CREATES VERSION WITHOUT PRERELEASE
|
52 | 89 | testargs = ["cz", "bump"]
|
53 | 90 | mocker.patch.object(sys, "argv", testargs)
|
54 | 91 | cli.main()
|
55 | 92 |
|
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") |
69 | 94 | assert tag_exists is True
|
70 | 95 |
|
71 | 96 |
|
|
0 commit comments