Skip to content

Commit 69a292d

Browse files
committed
test(release): allow an empty post-cut changelog inventory
1 parent d6edc8e commit 69a292d

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

tests/test_changelog_fragment_contract.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ def test_rubric_slice_is_release_noted_in_the_published_changelog():
6565

6666

6767
def test_every_repository_fragment_matches_the_authoritative_format():
68-
"""A release cannot silently omit a malformed or unclassified fragment."""
68+
"""Every extant fragment must render; an empty post-release inventory is valid."""
6969
module = _module()
7070
paths = module.fragment_paths()
71-
assert paths
7271
rendered = module.render_unreleased(paths)
72+
if not paths:
73+
assert rendered == "## Unreleased\n"
7374
for path in paths:
7475
title, _ = module.parse_fragment(path)
7576
assert f"#### {title}" in rendered
@@ -120,6 +121,22 @@ def test_changelog_check_update_round_trip_preserves_manual_notes_and_history(
120121
assert f"{module.END_MARKER}\n\n## [1.0.0]" in rewritten
121122

122123

124+
def test_empty_fragment_inventory_round_trips_after_release(tmp_path):
125+
"""A complete release may leave no authoritative Unreleased fragments."""
126+
module = _module()
127+
changelog = tmp_path / "CHANGELOG.md"
128+
changelog.write_text(_changelog(), encoding="utf-8")
129+
rendered = module.render_unreleased(())
130+
assert rendered == "## Unreleased\n"
131+
132+
module.update_changelog(changelog, ())
133+
module.check_changelog(changelog, ())
134+
updated = changelog.read_text(encoding="utf-8")
135+
assert f"{module.BEGIN_MARKER}\n{module.END_MARKER}" in updated
136+
assert f"{module.END_MARKER}\n\n## [1.0.0]" in updated
137+
assert "- Manual note." in updated
138+
139+
123140
def test_changelog_sync_rejects_ambiguous_headings_and_markers(tmp_path):
124141
"""Duplicate headings, incomplete markers, and out-of-section markers fail."""
125142
module = _module()
@@ -181,12 +198,9 @@ def test_cli_check_and_update_modes_are_fail_closed(tmp_path, capsys):
181198
assert module.main(["--check", str(changelog)]) == 0
182199

183200

184-
def test_render_contract_rejects_empty_and_malformed_fragments(tmp_path):
185-
"""Malformed or empty fragment inventories cannot produce release evidence."""
201+
def test_render_contract_rejects_malformed_fragments(tmp_path):
202+
"""Malformed fragments cannot produce release evidence."""
186203
module = _module()
187-
with pytest.raises(ValueError, match="at least one"):
188-
module.render_unreleased(())
189-
190204
malformed = tmp_path / "bad.md"
191205
malformed.write_text("not a title\n", encoding="utf-8")
192206
with pytest.raises(ValueError, match="level-one title"):

0 commit comments

Comments
 (0)