|
2 | 2 | CC: Conventional commits
|
3 | 3 | SVE: Semantic version at the end
|
4 | 4 | """
|
| 5 | +import pytest |
| 6 | + |
5 | 7 | from commitizen import bump
|
6 | 8 | from commitizen.git import GitCommit
|
7 | 9 |
|
|
44 | 46 | semantic_version_map = {"MAJOR": "MAJOR", "MINOR": "MINOR", "PATCH": "PATCH"}
|
45 | 47 |
|
46 | 48 |
|
47 |
| -def test_find_increment_type_patch(): |
48 |
| - messages = PATCH_INCREMENTS_CC |
49 |
| - commits = [GitCommit(rev="test", title=message) for message in messages] |
50 |
| - increment_type = bump.find_increment(commits) |
51 |
| - assert increment_type == "PATCH" |
52 |
| - |
53 |
| - |
54 |
| -def test_find_increment_type_minor(): |
55 |
| - messages = MINOR_INCREMENTS_CC |
| 49 | +@pytest.mark.parametrize( |
| 50 | + "messages, expected_type", |
| 51 | + ( |
| 52 | + (PATCH_INCREMENTS_CC, "PATCH"), |
| 53 | + (MINOR_INCREMENTS_CC, "MINOR"), |
| 54 | + (MAJOR_INCREMENTS_CC, "MAJOR"), |
| 55 | + (NONE_INCREMENT_CC, None), |
| 56 | + ), |
| 57 | +) |
| 58 | +def test_find_increment(messages, expected_type): |
56 | 59 | commits = [GitCommit(rev="test", title=message) for message in messages]
|
57 | 60 | increment_type = bump.find_increment(commits)
|
58 |
| - assert increment_type == "MINOR" |
59 |
| - |
60 |
| - |
61 |
| -def test_find_increment_type_major(): |
62 |
| - messages = MAJOR_INCREMENTS_CC |
63 |
| - commits = [GitCommit(rev="test", title=message) for message in messages] |
64 |
| - increment_type = bump.find_increment(commits) |
65 |
| - assert increment_type == "MAJOR" |
66 |
| - |
67 |
| - |
68 |
| -def test_find_increment_type_patch_sve(): |
69 |
| - messages = PATCH_INCREMENTS_SVE |
70 |
| - commits = [GitCommit(rev="test", title=message) for message in messages] |
71 |
| - increment_type = bump.find_increment( |
72 |
| - commits, regex=semantic_version_pattern, increments_map=semantic_version_map |
73 |
| - ) |
74 |
| - assert increment_type == "PATCH" |
75 |
| - |
76 |
| - |
77 |
| -def test_find_increment_type_minor_sve(): |
78 |
| - messages = MINOR_INCREMENTS_SVE |
79 |
| - commits = [GitCommit(rev="test", title=message) for message in messages] |
80 |
| - increment_type = bump.find_increment( |
81 |
| - commits, regex=semantic_version_pattern, increments_map=semantic_version_map |
82 |
| - ) |
83 |
| - assert increment_type == "MINOR" |
84 |
| - |
85 |
| - |
86 |
| -def test_find_increment_type_major_sve(): |
87 |
| - messages = MAJOR_INCREMENTS_SVE |
88 |
| - commits = [GitCommit(rev="test", title=message) for message in messages] |
89 |
| - increment_type = bump.find_increment( |
90 |
| - commits, regex=semantic_version_pattern, increments_map=semantic_version_map |
91 |
| - ) |
92 |
| - assert increment_type == "MAJOR" |
93 |
| - |
94 |
| - |
95 |
| -def test_find_increment_type_none(): |
96 |
| - messages = NONE_INCREMENT_CC |
| 61 | + assert increment_type == expected_type |
| 62 | + |
| 63 | + |
| 64 | +@pytest.mark.parametrize( |
| 65 | + "messages, expected_type", |
| 66 | + ( |
| 67 | + (PATCH_INCREMENTS_SVE, "PATCH"), |
| 68 | + (MINOR_INCREMENTS_SVE, "MINOR"), |
| 69 | + (MAJOR_INCREMENTS_SVE, "MAJOR"), |
| 70 | + ), |
| 71 | +) |
| 72 | +def test_find_increment_sve(messages, expected_type): |
97 | 73 | commits = [GitCommit(rev="test", title=message) for message in messages]
|
98 | 74 | increment_type = bump.find_increment(
|
99 | 75 | commits, regex=semantic_version_pattern, increments_map=semantic_version_map
|
100 | 76 | )
|
101 |
| - assert increment_type is None |
| 77 | + assert increment_type == expected_type |
0 commit comments