import test from 'node:test'; import assert from 'node:assert/strict'; import releasePolicy from '../src/shared/release-policy.cjs'; const { windowsReleaseAssetNames, existingReleaseState } = releasePolicy; const commit = 'a'.repeat(40); const version = '0.10.16'; test('a draft for another commit cannot receive replacement release assets', () => { assert.throws(() => existingReleaseState({ target_commitish: 'b'.repeat(40), draft: true }, version, commit), /Bump the version/); }); test('a matching draft can resume while a complete published release is immutable', () => { assert.equal(existingReleaseState({ target_commitish: commit, draft: true }, version, commit), 'draft'); assert.equal(existingReleaseState({ target_commitish: commit, draft: false, assets: windowsReleaseAssetNames(version).map((name) => ({ name })) }, version, commit), 'published'); }); test('a published release missing its signature cannot be treated as complete', () => { const assets = windowsReleaseAssetNames(version).filter((name) => !name.endsWith('.sig')).map((name) => ({ name })); assert.throws(() => existingReleaseState({ target_commitish: commit, draft: false, assets }, version, commit), /release-manifest.json.sig/); });