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 d5b67b0

Browse files
committed
test(changelog): code coverage improvements
1 parent 991e829 commit d5b67b0

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎commitizen/commands/changelog.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
from commitizen.git import GitTag, smart_open
1717

1818

19-
def similar(a, b):
20-
return SequenceMatcher(None, a, b).ratio()
21-
22-
2319
class Changelog:
2420
"""Generate a changelog based on the commit history."""
2521

‎tests/commands/test_changelog_command.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,15 @@ def test_changelog_without_revision(mocker, tmp_commitizen_project):
351351
cli.main()
352352

353353

354+
def test_changelog_incremental_with_revision(mocker):
355+
"""combining incremental with a revision doesn't make sense"""
356+
testargs = ["cz", "changelog", "--incremental", "0.2.0"]
357+
mocker.patch.object(sys, "argv", testargs)
358+
359+
with pytest.raises(NotAllowed):
360+
cli.main()
361+
362+
354363
def test_changelog_with_different_tag_name_and_changelog_content(
355364
mocker, tmp_commitizen_project
356365
):
@@ -918,3 +927,15 @@ def test_changelog_with_customized_change_type_order(
918927
out = f.read()
919928

920929
file_regression.check(out, extension=".md")
930+
931+
932+
@pytest.mark.usefixtures("tmp_commitizen_project")
933+
def test_empty_commit_list(mocker):
934+
create_file_and_commit("feat: a new world")
935+
936+
# test changelog properly handles when no commits are found for the revision
937+
mocker.patch("commitizen.git.get_commits", return_value=[])
938+
testargs = ["cz", "changelog"]
939+
mocker.patch.object(sys, "argv", testargs)
940+
with pytest.raises(NoCommitsFoundError):
941+
cli.main()

0 commit comments

Comments
(0)

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