Skip to content

Commit b91ce9f

Browse files
committed
test(test_changelog_command.py): add test for changelog file_name construction from args and config
1 parent 2090b7c commit b91ce9f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_changelog.py

+32
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
from dataclasses import dataclass
33
from pathlib import Path
44
from typing import Optional
5+
from unittest.mock import Mock
56

67
import pytest
78
from jinja2 import FileSystemLoader
89

910
from commitizen import changelog, git
1011
from commitizen.changelog_formats import ChangelogFormat
12+
from commitizen.commands.changelog import Changelog
13+
from commitizen.config import BaseConfig
1114
from commitizen.cz.conventional_commits.conventional_commits import (
1215
ConventionalCommitsCz,
1316
)
@@ -1560,3 +1563,32 @@ def test_tags_rules_get_version_tags(capsys: pytest.CaptureFixture):
15601563
captured = capsys.readouterr()
15611564
assert captured.err.count("InvalidVersion") == 2
15621565
assert captured.err.count("not-a-version") == 2
1566+
1567+
1568+
def test_changelog_file_name_from_args_and_config():
1569+
mock_config = Mock(spec=BaseConfig)
1570+
mock_config.path.parent = "/my/project/"
1571+
mock_config.settings = {
1572+
"name": "cz_conventional_commits",
1573+
"changelog_file": "CHANGELOG.md",
1574+
"encoding": "utf-8",
1575+
"changelog_start_rev": "v1.0.0",
1576+
"tag_format": "$version",
1577+
"legacy_tag_formats": [],
1578+
"ignored_tag_formats": [],
1579+
"incremental": True,
1580+
"changelog_merge_prerelease": True,
1581+
}
1582+
1583+
args = {
1584+
"file_name": "CUSTOM.md",
1585+
"incremental": None,
1586+
"dry_run": False,
1587+
"unreleased_version": "1.0.1",
1588+
}
1589+
changelog = Changelog(mock_config, args)
1590+
assert changelog.file_name == "/my/project/CUSTOM.md"
1591+
1592+
args = {"incremental": None, "dry_run": False, "unreleased_version": "1.0.1"}
1593+
changelog = Changelog(mock_config, args)
1594+
assert changelog.file_name == "/my/project/CHANGELOG.md"

0 commit comments

Comments
 (0)