Skip to content

Commit a9f6194

Browse files
Reproduce unverified draft metadata before publication
(cherry picked from commit bf242f2)
1 parent 33c2050 commit a9f6194

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎.github/actions/Publish-PSModule/tests/Publish-PSModule.Preflight.Tests.ps1‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,34 @@ Describe 'Publish-PSModule source-bound preflight' {
854854
$script:state.GitHubWrites | Should -Be 0
855855
}
856856

857+
It 'rejects <Shape> draft metadata before Gallery or GitHub writes' -ForEach @(
858+
@{ Shape = 'missing' }
859+
@{ Shape = 'null' }
860+
@{ Shape = 'string false' }
861+
@{ Shape = 'array false' }
862+
) {
863+
Set-PSModuleFixtureClaim -State $script:state -Claim $script:state.ExpectedClaim
864+
$release = [pscustomobject]@{
865+
tag_name = 'v1.2.4'; html_url = 'https://github.com/PSModule/TestModule/releases/tag/v1.2.4'
866+
prerelease = $false; body = 'Direct release notes.'; assets = @()
867+
}
868+
if ($Shape -ceq 'null') {
869+
$release | Add-Member -NotePropertyName draft -NotePropertyValue $null
870+
} elseif ($Shape -ceq 'string false') {
871+
$release | Add-Member -NotePropertyName draft -NotePropertyValue 'false'
872+
} elseif ($Shape -ceq 'array false') {
873+
$release | Add-Member -NotePropertyName draft -NotePropertyValue @($false)
874+
}
875+
$script:state.ApiResponses['repos/PSModule/TestModule/releases/tags/v1.2.4'] = $release
876+
877+
$failure = $null
878+
try { & $script:publishScriptPath 1>$null 6>$null } catch { $failure = $_ }
879+
880+
$script:state.GalleryWrites | Should -Be 0
881+
$script:state.GitHubWrites | Should -Be 0
882+
$failure.Exception.Message | Should -Match 'draft|published'
883+
}
884+
857885
It 'rejects a competing module/version claim under another prefix with identical bytes' {
858886
$foreign = $script:state.ExpectedClaim | ConvertTo-Json -Compress | ConvertFrom-Json
859887
$foreign.CommitSha = '2222222222222222222222222222222222222222'

0 commit comments

Comments
 (0)