From 96f88c70e69d587e9c5821ea2777677c5fb1264c Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 7 Apr 2026 21:32:46 +0300 Subject: feat: add release state verification --- scripts/test_changelog.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'scripts/test_changelog.py') diff --git a/scripts/test_changelog.py b/scripts/test_changelog.py index 6821dc38..10af5c47 100644 --- a/scripts/test_changelog.py +++ b/scripts/test_changelog.py @@ -6,8 +6,10 @@ import unittest from scripts.changelog import ( ChangelogError, build_latest_json, + canonicalize_manifest, default_release_assets, ensure_manifest_is_outdated, + ensure_manifest_matches_expected, extract_section_body, manifest_from_release_payload, prepare_release, @@ -129,6 +131,72 @@ class ChangelogScriptTests(unittest.TestCase): def test_ensure_manifest_is_outdated_allows_older_version(self) -> None: ensure_manifest_is_outdated({"version": "0.1.0"}, "0.1.1") + def test_canonicalize_manifest_requires_all_asset_targets(self) -> None: + with self.assertRaisesRegex(ChangelogError, "missing asset URL for macos-aarch64"): + canonicalize_manifest( + { + "version": "0.1.1", + "notes": "### Fixed\n- One", + "assets": { + "linux-x86_64": "https://example.com/linux-x86_64", + "linux-aarch64": "https://example.com/linux-aarch64", + "macos-x86_64": "https://example.com/macos-x86_64", + }, + }, + "test manifest", + ) + + def test_ensure_manifest_matches_expected_normalizes_whitespace(self) -> None: + actual = { + "version": "v0.1.1", + "notes": "\n### Fixed\n- One\n", + "assets": { + "linux-x86_64": " https://example.com/linux-x86_64 ", + "linux-aarch64": "https://example.com/linux-aarch64", + "macos-x86_64": "https://example.com/macos-x86_64", + "macos-aarch64": "https://example.com/macos-aarch64", + }, + } + expected = { + "version": "0.1.1", + "notes": "### Fixed\n- One", + "assets": { + "linux-x86_64": "https://example.com/linux-x86_64", + "linux-aarch64": "https://example.com/linux-aarch64", + "macos-x86_64": "https://example.com/macos-x86_64", + "macos-aarch64": "https://example.com/macos-aarch64", + }, + } + + canonical = ensure_manifest_matches_expected(actual, expected, "test manifest") + self.assertEqual(canonical, expected) + + def test_ensure_manifest_matches_expected_rejects_different_notes(self) -> None: + with self.assertRaisesRegex(ChangelogError, "does not match the published GitHub release manifest"): + ensure_manifest_matches_expected( + { + "version": "0.1.1", + "notes": "### Fixed\n- Different", + "assets": { + "linux-x86_64": "https://example.com/linux-x86_64", + "linux-aarch64": "https://example.com/linux-aarch64", + "macos-x86_64": "https://example.com/macos-x86_64", + "macos-aarch64": "https://example.com/macos-aarch64", + }, + }, + { + "version": "0.1.1", + "notes": "### Fixed\n- One", + "assets": { + "linux-x86_64": "https://example.com/linux-x86_64", + "linux-aarch64": "https://example.com/linux-aarch64", + "macos-x86_64": "https://example.com/macos-x86_64", + "macos-aarch64": "https://example.com/macos-aarch64", + }, + }, + "test manifest", + ) + if __name__ == "__main__": unittest.main() -- cgit v1.2.3