|
5 | 5 | import pytest
|
6 | 6 | from packaging.version import Version
|
7 | 7 |
|
8 | | -from commitizen import bump, cli, cmd |
| 8 | +from commitizen import bump, cli, cmd, exceptions |
9 | 9 |
|
10 | 10 | conversion = [
|
11 | 11 | (
|
@@ -68,3 +68,32 @@ def test_bump_pre_commit_changelog(tmp_commitizen_project, mocker, freezer, retr
|
68 | 68 | - \\_test
|
69 | 69 | """
|
70 | 70 | )
|
| 71 | + |
| 72 | + |
| 73 | +@pytest.mark.parametrize("retry", (True, False)) |
| 74 | +def test_bump_pre_commit_changelog_fails_always( |
| 75 | + tmp_commitizen_project, mocker, freezer, retry |
| 76 | +): |
| 77 | + freezer.move_to("2022年04月01日") |
| 78 | + testargs = ["cz", "bump", "--changelog", "--yes"] |
| 79 | + if retry: |
| 80 | + testargs.append("--retry") |
| 81 | + mocker.patch.object(sys, "argv", testargs) |
| 82 | + with tmp_commitizen_project.as_cwd(): |
| 83 | + Path(".pre-commit-config.yaml").write_text( |
| 84 | + """ |
| 85 | + repos: |
| 86 | + - repo: local |
| 87 | + hooks: |
| 88 | + - id: forbid-changelog |
| 89 | + name: changelogs are forbidden |
| 90 | + entry: changelogs are forbidden |
| 91 | + language: fail |
| 92 | + files: CHANGELOG.md |
| 93 | + """ |
| 94 | + ) |
| 95 | + cmd.run("git add -A") |
| 96 | + cmd.run("git commit -m 'feat: forbid changelogs'") |
| 97 | + cmd.run("pre-commit install") |
| 98 | + with pytest.raises(exceptions.BumpCommitFailedError): |
| 99 | + cli.main() |
0 commit comments