Skip to content

Commit 85003e1

Browse files
Reproduce original event context projection before publisher validation
(cherry picked from commit 131c30b)
1 parent 6abfb43 commit 85003e1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,31 @@ Describe 'Publish-PSModule source-bound preflight' {
541541
$script:state.GitHubWrites | Should -Be 0
542542
}
543543

544+
It 'rejects original event PR context before projection' -ForEach @(
545+
@{ EventJson = '{"pull_request":[{"number":42}]}' }
546+
@{ EventJson = '{"pull_request":{"number":[42]}}' }
547+
@{ EventJson = '[{"pull_request":{"number":42}}]' }
548+
@{ EventJson = '{"pull_request":{}}' }
549+
) {
550+
[IO.File]::WriteAllText($env:GITHUB_EVENT_PATH, $EventJson)
551+
552+
{ & $script:publishScriptPath 1>$null 6>$null } | Should -Throw '*context*'
553+
554+
$script:state.GalleryWrites | Should -Be 0
555+
$script:state.GitHubWrites | Should -Be 0
556+
}
557+
558+
It 'retains the valid producing event PR number before projection' {
559+
[IO.File]::WriteAllText($env:GITHUB_EVENT_PATH, '{"pull_request":{"number":42}}')
560+
$script:state.ExpectedClaim.PullRequest = 42
561+
562+
{ & $script:publishScriptPath 1>$null 6>$null } | Should -Not -Throw
563+
564+
$script:state.GalleryWrites | Should -Be 1
565+
$claim = Get-PSModulePublicationClaim -Message $script:state.TagObject.message
566+
$claim.PullRequest | Should -Be 42
567+
}
568+
544569
It 'rejects a draft release before Gallery publication rather than reporting completed publication' {
545570
Set-PSModuleFixtureClaim -State $script:state -Claim $script:state.ExpectedClaim
546571
$script:state.Release = [pscustomobject]@{

0 commit comments

Comments
 (0)