Skip to content

Commit b313847

Browse files
ongdishengLee-W
authored andcommitted
test(changelog): ensure error on missing changelog template filename
1 parent d8b135a commit b313847

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎tests/commands/test_changelog_command.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,32 @@ def test_export_changelog_template_from_plugin(
19141914
asserttarget.read_text() ==tpl
19151915

19161916

1917+
deftest_export_changelog_template_fails_when_template_has_no_filename(
1918+
mocker: MockFixture,
1919+
tmp_commitizen_project: Path,
1920+
):
1921+
project_root=Path(tmp_commitizen_project)
1922+
target=project_root/"changelog.jinja"
1923+
1924+
# Mock a template object with no filename
1925+
classFakeTemplate:
1926+
filename=None
1927+
1928+
# Patch get_changelog_template to return a template without a filename
1929+
mocker.patch(
1930+
"commitizen.changelog.get_changelog_template", return_value=FakeTemplate()
1931+
)
1932+
1933+
args= ["cz", "changelog", "--export-template", str(target)]
1934+
mocker.patch.object(sys, "argv", args)
1935+
1936+
withpytest.raises(NotAllowed) asexc_info:
1937+
cli.main()
1938+
1939+
assertnottarget.exists()
1940+
assert"Template filename is not set"instr(exc_info.value)
1941+
1942+
19171943
@skip_below_py_3_13
19181944
deftest_changelog_command_shows_description_when_use_help_option(
19191945
mocker: MockFixture, capsys, file_regression

0 commit comments

Comments
(0)