Skip to content

Commit 3fede81

Browse files
committed
test(cmd-changelog): improve resilency & drop unnecessary test cases for no-op
1 parent c159bce commit 3fede81

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

tests/e2e/cmd_changelog/test_changelog.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
example_changelog_rst,
3636
)
3737
from tests.fixtures.repos import (
38+
get_versions_for_trunk_only_repo_w_no_tags,
3839
get_versions_for_trunk_only_repo_w_prerelease_tags,
40+
get_versions_for_trunk_only_repo_w_tags,
3941
repo_w_git_flow_and_release_channels_angular_commits,
4042
repo_w_git_flow_and_release_channels_angular_commits_using_tag_format,
4143
repo_w_git_flow_and_release_channels_emoji_commits,
@@ -86,42 +88,37 @@
8688
)
8789

8890

91+
@pytest.mark.parametrize("arg0", [None, "--post-to-release-tag"])
8992
@pytest.mark.parametrize(
90-
"repo, tag",
93+
"repo, get_version_strings_fn",
9194
[
92-
(lazy_fixture(repo_w_no_tags_angular_commits.__name__), None),
93-
*[
94-
pytest.param(
95-
lazy_fixture(repo_fixture),
96-
tag,
97-
marks=pytest.mark.comprehensive,
98-
)
99-
for repo_fixture, tag in (
100-
(repo_w_trunk_only_angular_commits.__name__, "v0.1.1"),
101-
(
102-
repo_w_trunk_only_n_prereleases_angular_commits.__name__,
103-
"v0.2.0",
104-
),
105-
(
106-
repo_w_github_flow_w_feature_release_channel_angular_commits.__name__,
107-
"v0.2.0",
108-
),
109-
(repo_w_git_flow_angular_commits.__name__, "v1.0.0"),
110-
(
111-
repo_w_git_flow_and_release_channels_angular_commits.__name__,
112-
"v1.1.0",
113-
),
114-
)
115-
],
95+
(
96+
lazy_fixture(repo_fixture),
97+
lazy_fixture(get_versions_fn),
98+
)
99+
for repo_fixture, get_versions_fn in (
100+
# Only need to test when it has tags or no tags
101+
# DO NOT need to consider all repo types as it doesn't change no-op behavior
102+
(
103+
repo_w_no_tags_angular_commits.__name__,
104+
get_versions_for_trunk_only_repo_w_no_tags.__name__,
105+
),
106+
(
107+
repo_w_trunk_only_angular_commits.__name__,
108+
get_versions_for_trunk_only_repo_w_tags.__name__,
109+
),
110+
)
116111
],
117112
)
118-
@pytest.mark.parametrize("arg0", [None, "--post-to-release-tag"])
119113
def test_changelog_noop_is_noop(
120114
repo: Repo,
121-
tag: str | None,
115+
get_version_strings_fn: GetVersionStringsFn,
122116
arg0: str | None,
123117
cli_runner: CliRunner,
124118
):
119+
if (version_str := get_version_strings_fn()[-1]) == "Unreleased":
120+
version_str = None
121+
125122
repo.git.reset("--hard")
126123

127124
# Set up a requests HTTP session so we can catch the HTTP calls and ensure
@@ -140,7 +137,7 @@ def test_changelog_noop_is_noop(
140137
get_func_qual_name(semantic_release.hvcs.github.build_requests_session),
141138
return_value=session,
142139
), requests_mock.Mocker(session=session) as mocker:
143-
args = [arg0, tag] if tag and arg0 else []
140+
args = [arg0, f"v{version_str}"] if version_str and arg0 else []
144141
cli_cmd = [MAIN_PROG_NAME, "--noop", CHANGELOG_SUBCMD, *args]
145142
result = cli_runner.invoke(main, cli_cmd[1:])
146143

0 commit comments

Comments
 (0)