Skip to content

Commit bf242f2

Browse files
Reproduce unverified draft metadata before publication
1 parent 8ed2377 commit bf242f2

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
@@ -837,6 +837,34 @@ Describe 'Publish-PSModule source-bound preflight' {
837837
$script:state.GitHubWrites | Should -Be 0
838838
}
839839

840+
It 'rejects <Shape> draft metadata before Gallery or GitHub writes' -ForEach @(
841+
@{ Shape = 'missing' }
842+
@{ Shape = 'null' }
843+
@{ Shape = 'string false' }
844+
@{ Shape = 'array false' }
845+
) {
846+
Set-PSModuleFixtureClaim -State $script:state -Claim $script:state.ExpectedClaim
847+
$release = [pscustomobject]@{
848+
tag_name = 'v1.2.4'; html_url = 'https://github.com/PSModule/TestModule/releases/tag/v1.2.4'
849+
prerelease = $false; body = 'Direct release notes.'; assets = @()
850+
}
851+
if ($Shape -ceq 'null') {
852+
$release | Add-Member -NotePropertyName draft -NotePropertyValue $null
853+
} elseif ($Shape -ceq 'string false') {
854+
$release | Add-Member -NotePropertyName draft -NotePropertyValue 'false'
855+
} elseif ($Shape -ceq 'array false') {
856+
$release | Add-Member -NotePropertyName draft -NotePropertyValue @($false)
857+
}
858+
$script:state.ApiResponses['repos/PSModule/TestModule/releases/tags/v1.2.4'] = $release
859+
860+
$failure = $null
861+
try { & $script:publishScriptPath 1>$null 6>$null } catch { $failure = $_ }
862+
863+
$script:state.GalleryWrites | Should -Be 0
864+
$script:state.GitHubWrites | Should -Be 0
865+
$failure.Exception.Message | Should -Match 'draft|published'
866+
}
867+
840868
It 'rejects a competing module/version claim under another prefix with identical bytes' {
841869
$foreign = $script:state.ExpectedClaim | ConvertTo-Json -Compress | ConvertFrom-Json
842870
$foreign.CommitSha = '2222222222222222222222222222222222222222'

0 commit comments

Comments
 (0)