Skip to content

fix: cz bump subdir #1391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(test_changelog_command.py): add test for changelog file_name con…
…struction from args and config
  • Loading branch information
Yusin0903 committed Apr 15, 2025
commit b91ce9fcf19aa1697c92c35b548a58871da1503f
32 changes: 32 additions & 0 deletions tests/test_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
from dataclasses import dataclass
from pathlib import Path
from typing import Optional
from unittest.mock import Mock

import pytest
from jinja2 import FileSystemLoader

from commitizen import changelog, git
from commitizen.changelog_formats import ChangelogFormat
from commitizen.commands.changelog import Changelog
from commitizen.config import BaseConfig
from commitizen.cz.conventional_commits.conventional_commits import (
ConventionalCommitsCz,
)
Expand Down Expand Up @@ -1560,3 +1563,32 @@ def test_tags_rules_get_version_tags(capsys: pytest.CaptureFixture):
captured = capsys.readouterr()
assert captured.err.count("InvalidVersion") == 2
assert captured.err.count("not-a-version") == 2


def test_changelog_file_name_from_args_and_config():
mock_config = Mock(spec=BaseConfig)
mock_config.path.parent = "/my/project/"
mock_config.settings = {
"name": "cz_conventional_commits",
"changelog_file": "CHANGELOG.md",
"encoding": "utf-8",
"changelog_start_rev": "v1.0.0",
"tag_format": "$version",
"legacy_tag_formats": [],
"ignored_tag_formats": [],
"incremental": True,
"changelog_merge_prerelease": True,
}

args = {
"file_name": "CUSTOM.md",
"incremental": None,
"dry_run": False,
"unreleased_version": "1.0.1",
}
changelog = Changelog(mock_config, args)
assert changelog.file_name == "/my/project/CUSTOM.md"

args = {"incremental": None, "dry_run": False, "unreleased_version": "1.0.1"}
changelog = Changelog(mock_config, args)
assert changelog.file_name == "/my/project/CHANGELOG.md"