-
-
Notifications
You must be signed in to change notification settings - Fork 296
test(cz_customize): add missing YAML configuration file tests #1516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b31f5f7
94642be
5a5ae74
daf1680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,13 +110,13 @@ And the correspondent example for a yaml file: | |
commitizen: | ||
name: cz_customize | ||
customize: | ||
message_template: "{{change_type}}:{% if show_message %} {{message}}{% endif %}" | ||
message_template: '{{change_type}}:{% if show_message %} {{message}}{% endif %}' | ||
example: 'feature: this feature enable customize through config file' | ||
schema: "<type>: <body>" | ||
schema_pattern: "(feature|bug fix):(\\s.*)" | ||
bump_pattern: "^(break|new|fix|hotfix)" | ||
commit_parser: "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?" | ||
changelog_pattern: "^(feature|bug fix)?(!)?" | ||
schema: '<type>: <body>' | ||
schema_pattern: '(feature|bug fix):(\\s.*)' | ||
bump_pattern: '^(break|new|fix|hotfix)' | ||
commit_parser: '^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?' | ||
changelog_pattern: '^(feature|bug fix)?(!)?' | ||
Comment on lines
+113
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why we need to change it 🤔 |
||
change_type_map: | ||
feature: Feat | ||
bug fix: Fix | ||
|
@@ -125,7 +125,7 @@ commitizen: | |
new: MINOR | ||
fix: PATCH | ||
hotfix: PATCH | ||
change_type_order: ["BREAKING CHANGE", "feat", "fix", "refactor", "perf"] | ||
change_type_order: ['BREAKING CHANGE', 'feat', 'fix', 'refactor', 'perf'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
info_path: cz_customize_info.txt | ||
info: This is customized info | ||
questions: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,6 +324,68 @@ def test_commit_when_nothing_to_commit(config, mocker: MockFixture): | |
assert "No files added to staging!" in str(excinfo.value) | ||
|
||
|
||
@pytest.mark.usefixtures("staging_is_clean") | ||
def test_commit_when_nothing_added_to_commit(config, mocker: MockFixture): | ||
prompt_mock = mocker.patch("questionary.prompt") | ||
prompt_mock.return_value = { | ||
"prefix": "feat", | ||
"subject": "user created", | ||
"scope": "", | ||
"is_breaking_change": False, | ||
"body": "", | ||
"footer": "", | ||
} | ||
|
||
commit_mock = mocker.patch("commitizen.git.commit") | ||
commit_mock.return_value = cmd.Command( | ||
'nothing added to commit but untracked files present (use "git add" to track)', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we might encounter issue if the language is not set to en_US. probably worth setting it up for this test |
||
"", | ||
b"", | ||
b"", | ||
0, | ||
) | ||
|
||
error_mock = mocker.patch("commitizen.out.error") | ||
|
||
commands.Commit(config, {"all": False})() | ||
|
||
prompt_mock.assert_called_once() | ||
error_mock.assert_called_once() | ||
|
||
assert "nothing added" in error_mock.call_args[0][0] | ||
|
||
|
||
@pytest.mark.usefixtures("staging_is_clean") | ||
def test_commit_when_no_changes_added_to_commit(config, mocker: MockFixture): | ||
prompt_mock = mocker.patch("questionary.prompt") | ||
prompt_mock.return_value = { | ||
"prefix": "feat", | ||
"subject": "user created", | ||
"scope": "", | ||
"is_breaking_change": False, | ||
"body": "", | ||
"footer": "", | ||
} | ||
|
||
commit_mock = mocker.patch("commitizen.git.commit") | ||
commit_mock.return_value = cmd.Command( | ||
'no changes added to commit (use "git add" and/or "git commit -a")', | ||
"", | ||
b"", | ||
b"", | ||
0, | ||
) | ||
|
||
error_mock = mocker.patch("commitizen.out.error") | ||
|
||
commands.Commit(config, {"all": False})() | ||
|
||
prompt_mock.assert_called_once() | ||
error_mock.assert_called_once() | ||
|
||
assert "no changes added to commit" in error_mock.call_args[0][0] | ||
|
||
|
||
@pytest.mark.usefixtures("staging_is_clean") | ||
def test_commit_with_allow_empty(config, mocker: MockFixture): | ||
prompt_mock = mocker.patch("questionary.prompt") | ||
|