Skip to content

Commit 2d01dc5

Browse files
committed
test(changelog): code coverage improvements
1 parent 3c961cf commit 2d01dc5

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
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
@@ -364,6 +364,15 @@ def test_changelog_without_revision(mocker, tmp_commitizen_project):
364364
cli.main()
365365

366366

367+
def test_changelog_incremental_with_revision(mocker):
368+
"""combining incremental with a revision doesn't make sense"""
369+
testargs = ["cz", "changelog", "--incremental", "0.2.0"]
370+
mocker.patch.object(sys, "argv", testargs)
371+
372+
with pytest.raises(NotAllowed):
373+
cli.main()
374+
375+
367376
def test_changelog_with_different_tag_name_and_changelog_content(
368377
mocker, tmp_commitizen_project
369378
):
@@ -894,3 +903,15 @@ def test_invalid_subject_is_skipped(mocker, capsys):
894903
out, _ = capsys.readouterr()
895904

896905
assert out == ("## Unreleased\n\n### Feat\n\n- a new world\n\n")
906+
907+
908+
@pytest.mark.usefixtures("tmp_commitizen_project")
909+
def test_empty_commit_list(mocker):
910+
create_file_and_commit("feat: a new world")
911+
912+
# test changelog properly handles when no commits are found for the revision
913+
mocker.patch("commitizen.git.get_commits", return_value=[])
914+
testargs = ["cz", "changelog"]
915+
mocker.patch.object(sys, "argv", testargs)
916+
with pytest.raises(NoCommitsFoundError):
917+
cli.main()

0 commit comments

Comments
 (0)