15
15
from tests .utils import create_file_and_commit , wait_for_tag
16
16
17
17
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
-
29
18
@pytest .mark .usefixtures ("tmp_commitizen_project" )
30
19
def test_changelog_from_version_zero_point_two (mocker , capsys , file_regression ):
31
20
create_file_and_commit ("feat: new file" )
@@ -351,6 +340,15 @@ def test_changelog_without_revision(mocker, tmp_commitizen_project):
351
340
cli .main ()
352
341
353
342
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
+
354
352
def test_changelog_with_different_tag_name_and_changelog_content (
355
353
mocker , tmp_commitizen_project
356
354
):
@@ -633,6 +631,7 @@ def test_changelog_from_rev_latest_version_from_arg(
633
631
def test_changelog_from_rev_single_version_not_found (
634
632
mocker , config_path , changelog_path
635
633
):
634
+ """Provides an invalid revision ID to changelog command"""
636
635
with open (config_path , "a" ) as f :
637
636
f .write ('tag_format = "$version"\n ' )
638
637
@@ -657,12 +656,13 @@ def test_changelog_from_rev_single_version_not_found(
657
656
with pytest .raises (NoCommitsFoundError ) as excinfo :
658
657
cli .main ()
659
658
660
- assert "No commits found " in str (excinfo )
659
+ assert "Could not find a valid revision " in str (excinfo )
661
660
662
661
663
662
@pytest .mark .usefixtures ("tmp_commitizen_project" )
664
663
@pytest .mark .freeze_time ("2022-02-13" )
665
664
def test_changelog_from_rev_range_version_not_found (mocker , config_path ):
665
+ """Provides an invalid end revision ID to changelog command"""
666
666
with open (config_path , "a" ) as f :
667
667
f .write ('tag_format = "$version"\n ' )
668
668
@@ -684,7 +684,7 @@ def test_changelog_from_rev_range_version_not_found(mocker, config_path):
684
684
with pytest .raises (NoCommitsFoundError ) as excinfo :
685
685
cli .main ()
686
686
687
- assert "No commits found " in str (excinfo )
687
+ assert "Could not find a valid revision " in str (excinfo )
688
688
689
689
690
690
@pytest .mark .usefixtures ("tmp_commitizen_project" )
@@ -916,3 +916,15 @@ def test_changelog_with_customized_change_type_order(
916
916
out = f .read ()
917
917
918
918
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