|
2 | 2 |
|
3 | 3 | import pytest |
4 | 4 |
|
5 | | -from conventional_pre_commit.hook import RESULT_SUCCESS, RESULT_FAIL, main |
| 5 | +from conventional_pre_commit.hook import RESULT_FAIL, RESULT_SUCCESS, main |
6 | 6 |
|
7 | 7 |
|
8 | 8 | @pytest.fixture |
@@ -46,6 +46,54 @@ def test_main_success__custom_conventional(conventional_commit_path): |
46 | 46 | assert result == RESULT_SUCCESS |
47 | 47 |
|
48 | 48 |
|
| 49 | +def test_main_success__conventional_utf8(conventional_utf8_commit_path): |
| 50 | + result = main([conventional_utf8_commit_path]) |
| 51 | + |
| 52 | + assert result == RESULT_SUCCESS |
| 53 | + |
| 54 | + |
| 55 | +def test_main_fail__conventional_gbk(conventional_gbk_commit_path): |
| 56 | + result = main([conventional_gbk_commit_path]) |
| 57 | + |
| 58 | + assert result == RESULT_FAIL |
| 59 | + |
| 60 | + |
| 61 | +def test_main_fail__conventional_with_scope(conventional_commit_path): |
| 62 | + result = main(["--force-scope", conventional_commit_path]) |
| 63 | + |
| 64 | + assert result == RESULT_FAIL |
| 65 | + |
| 66 | + |
| 67 | +def test_main_success__conventional_with_scope(cmd, conventional_commit_with_scope_path): |
| 68 | + result = main(["--force-scope", conventional_commit_with_scope_path]) |
| 69 | + |
| 70 | + assert result == RESULT_SUCCESS |
| 71 | + |
| 72 | + |
| 73 | +def test_main_success__fixup_commit(fixup_commit_path): |
| 74 | + result = main([fixup_commit_path]) |
| 75 | + |
| 76 | + assert result == RESULT_SUCCESS |
| 77 | + |
| 78 | + |
| 79 | +def test_main_fail__fixup_commit(fixup_commit_path): |
| 80 | + result = main(["--strict", fixup_commit_path]) |
| 81 | + |
| 82 | + assert result == RESULT_FAIL |
| 83 | + |
| 84 | + |
| 85 | +def test_main_success__conventional_commit_multi_line(conventional_commit_multi_line_path): |
| 86 | + result = main([conventional_commit_multi_line_path]) |
| 87 | + |
| 88 | + assert result == RESULT_SUCCESS |
| 89 | + |
| 90 | + |
| 91 | +def test_main_fail__conventional_commit_bad_multi_line(conventional_commit_bad_multi_line_path): |
| 92 | + result = main([conventional_commit_bad_multi_line_path]) |
| 93 | + |
| 94 | + assert result == RESULT_FAIL |
| 95 | + |
| 96 | + |
49 | 97 | def test_subprocess_fail__missing_args(cmd): |
50 | 98 | result = subprocess.call(cmd) |
51 | 99 |
|
@@ -82,55 +130,37 @@ def test_subprocess_success__custom_conventional(cmd, conventional_commit_path): |
82 | 130 | assert result == RESULT_SUCCESS |
83 | 131 |
|
84 | 132 |
|
85 | | -def test_main_success__conventional_utf8(conventional_utf8_commit_path): |
86 | | - result = main([conventional_utf8_commit_path]) |
87 | | - |
88 | | - assert result == RESULT_SUCCESS |
89 | | - |
90 | | - |
91 | | -def test_main_fail__conventional_gbk(conventional_gbk_commit_path): |
92 | | - result = main([conventional_gbk_commit_path]) |
93 | | - |
94 | | - assert result == RESULT_FAIL |
95 | | - |
96 | | - |
97 | | -def test_main_fail__conventional_with_scope(cmd, conventional_commit_path): |
| 133 | +def test_subprocess_fail__conventional_with_scope(cmd, conventional_commit_path): |
98 | 134 | result = subprocess.call((cmd, "--force-scope", conventional_commit_path)) |
99 | 135 |
|
100 | 136 | assert result == RESULT_FAIL |
101 | 137 |
|
102 | 138 |
|
103 | | -def test_main_success__conventional_with_scope(cmd, conventional_commit_with_scope_path): |
| 139 | +def test_subprocess_success__conventional_with_scope(cmd, conventional_commit_with_scope_path): |
104 | 140 | result = subprocess.call((cmd, "--force-scope", conventional_commit_with_scope_path)) |
105 | 141 |
|
106 | 142 | assert result == RESULT_SUCCESS |
107 | 143 |
|
108 | 144 |
|
109 | | -def test_main_success__fixup_commit(cmd, fixup_commit_path): |
| 145 | +def test_subprocess_success__fixup_commit(cmd, fixup_commit_path): |
110 | 146 | result = subprocess.call((cmd, fixup_commit_path)) |
111 | 147 |
|
112 | 148 | assert result == RESULT_SUCCESS |
113 | 149 |
|
114 | 150 |
|
115 | | -def test_main_success__fail_commit(cmd, fixup_commit_path): |
| 151 | +def test_subprocess_fail__fixup_commit(cmd, fixup_commit_path): |
116 | 152 | result = subprocess.call((cmd, "--strict", fixup_commit_path)) |
117 | 153 |
|
118 | 154 | assert result == RESULT_FAIL |
119 | 155 |
|
120 | 156 |
|
121 | | -def test_main_success__conventional_commit_multi_line(cmd, conventional_commit_multi_line_path): |
| 157 | +def test_subprocess_success__conventional_commit_multi_line(cmd, conventional_commit_multi_line_path): |
122 | 158 | result = subprocess.call((cmd, conventional_commit_multi_line_path)) |
123 | 159 |
|
124 | 160 | assert result == RESULT_SUCCESS |
125 | 161 |
|
126 | 162 |
|
127 | | -def test_main_success__conventional_commit_bad_multi_line(cmd, conventional_commit_bad_multi_line_path): |
| 163 | +def test_subprocess_fail__conventional_commit_bad_multi_line(cmd, conventional_commit_bad_multi_line_path): |
128 | 164 | result = subprocess.call((cmd, conventional_commit_bad_multi_line_path)) |
129 | 165 |
|
130 | | - assert result == RESULT_SUCCESS |
131 | | - |
132 | | - |
133 | | -def test_main_success__conventional_commit_bad_multi_line_strict(cmd, conventional_commit_bad_multi_line_path): |
134 | | - result = subprocess.call((cmd, "--strict", conventional_commit_bad_multi_line_path)) |
135 | | - |
136 | 166 | assert result == RESULT_FAIL |
0 commit comments