Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 44f5b3e

Browse files
yajoLee-W
authored andcommitted
test: assert that a failing commit condition will fail always, both with or without --retry
1 parent ed21541 commit 44f5b3e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

‎tests/test_bump_create_commit_message.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
from packaging.version import Version
77

8-
from commitizen import bump, cli, cmd
8+
from commitizen import bump, cli, cmd, exceptions
99

1010
conversion = [
1111
(
@@ -68,3 +68,32 @@ def test_bump_pre_commit_changelog(tmp_commitizen_project, mocker, freezer, retr
6868
- \\_test
6969
"""
7070
)
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /