-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Open
AdrianDC
wants to merge
4
commits into
commitizen-tools:master
Choose a base branch
from
AdrianDC:test-cz-customize
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b31f5f7
test(cz_customize): add missing YAML configuration file tests
AdrianDC 94642be
test(cz_customize): fix YAML test and docs configurations quotes
AdrianDC 5a5ae74
test(cz_customize): fix missing YAML test keys against JSON/TOML
AdrianDC daf1680
test(command): cover 'nothing added' and 'no changes added to commit'
AdrianDC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)?(!)?' | ||
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: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why we need to change it 🤔