1515from tests .utils import create_file_and_commit , wait_for_tag
1616
1717
18- @pytest .mark .usefixtures ("tmp_commitizen_project" )
19- def test_changelog_on_empty_project (mocker ):
20- testargs = ["cz" , "changelog" , "--dry-run" ]
21- mocker .patch .object (sys , "argv" , testargs )
22-
23- with pytest .raises (NoCommitsFoundError ) as excinfo :
24- cli .main ()
25-
26- assert "No commits found" in str (excinfo )
27-
28-
2918@pytest .mark .usefixtures ("tmp_commitizen_project" )
3019def test_changelog_from_version_zero_point_two (mocker , capsys , file_regression ):
3120 create_file_and_commit ("feat: new file" )
@@ -351,6 +340,15 @@ def test_changelog_without_revision(mocker, tmp_commitizen_project):
351340 cli .main ()
352341
353342
343+ def test_changelog_incremental_with_revision (mocker ):
344+ """combining incremental with a revision doesn't make sense"""
345+ testargs = ["cz" , "changelog" , "--incremental" , "0.2.0" ]
346+ mocker .patch .object (sys , "argv" , testargs )
347+
348+ with pytest .raises (NotAllowed ):
349+ cli .main ()
350+
351+
354352def test_changelog_with_different_tag_name_and_changelog_content (
355353 mocker , tmp_commitizen_project
356354):
@@ -633,6 +631,7 @@ def test_changelog_from_rev_latest_version_from_arg(
633631def test_changelog_from_rev_single_version_not_found (
634632 mocker , config_path , changelog_path
635633):
634+ """Provides an invalid revision ID to changelog command"""
636635 with open (config_path , "a" ) as f :
637636 f .write ('tag_format = "$version"\n ' )
638637
@@ -657,12 +656,13 @@ def test_changelog_from_rev_single_version_not_found(
657656 with pytest .raises (NoCommitsFoundError ) as excinfo :
658657 cli .main ()
659658
660- assert "No commits found " in str (excinfo )
659+ assert "Could not find a valid revision " in str (excinfo )
661660
662661
663662@pytest .mark .usefixtures ("tmp_commitizen_project" )
664663@pytest .mark .freeze_time ("2022-02-13" )
665664def test_changelog_from_rev_range_version_not_found (mocker , config_path ):
665+ """Provides an invalid end revision ID to changelog command"""
666666 with open (config_path , "a" ) as f :
667667 f .write ('tag_format = "$version"\n ' )
668668
@@ -684,7 +684,7 @@ def test_changelog_from_rev_range_version_not_found(mocker, config_path):
684684 with pytest .raises (NoCommitsFoundError ) as excinfo :
685685 cli .main ()
686686
687- assert "No commits found " in str (excinfo )
687+ assert "Could not find a valid revision " in str (excinfo )
688688
689689
690690@pytest .mark .usefixtures ("tmp_commitizen_project" )
@@ -916,3 +916,15 @@ def test_changelog_with_customized_change_type_order(
916916 out = f .read ()
917917
918918 file_regression .check (out , extension = ".md" )
919+
920+
921+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
922+ def test_empty_commit_list (mocker ):
923+ create_file_and_commit ("feat: a new world" )
924+
925+ # test changelog properly handles when no commits are found for the revision
926+ mocker .patch ("commitizen.git.get_commits" , return_value = [])
927+ testargs = ["cz" , "changelog" ]
928+ mocker .patch .object (sys , "argv" , testargs )
929+ with pytest .raises (NoCommitsFoundError ):
930+ cli .main ()
0 commit comments