@@ -327,4 +327,63 @@ Describe 'Publish-PSModule source-bound preflight' {
327327 $script :state.GitHubWrites | Should - Be 0
328328 $failure.Exception.Message | Should -Match ' pull request'
329329 }
330+
331+ It ' rejects an unreadable final ownership footer on a stable release' - ForEach @ (
332+ @ { Footer = ' <!-- PSModule.PrereleaseOwner:v2:e30= -->' }
333+ @ { Footer = ' <!-- PSModule.PrereleaseOwner:v1:not-base64 -->' }
334+ ) {
335+ Set-PSModuleFixtureClaim - State $script :state - Claim $script :state.ExpectedClaim
336+ $script :state.Release = [pscustomobject ]@ {
337+ tag_name = ' v1.2.4' ; html_url = ' https://github.com/PSModule/TestModule/releases/tag/v1.2.4'
338+ prerelease = $false ; draft = $false ; body = " Notes.`n $Footer " ; assets = @ ()
339+ }
340+
341+ { & $script :publishScriptPath 1> $null 6> $null } | Should - Throw ' *footer*'
342+
343+ $script :state.GalleryWrites | Should - Be 0
344+ $script :state.GitHubWrites | Should - Be 0
345+ }
346+
347+ It ' rejects a disappeared previously claimed tag rather than recreating it' {
348+ Set-PSModuleFixtureClaim - State $script :state - Claim $script :state.ExpectedClaim
349+ $script :state.OnTagRead = {
350+ param ($State )
351+ if ($State.TagReads -eq 2 ) {
352+ $State.Tag = $null
353+ $State.TagObject = $null
354+ }
355+ }
356+
357+ { & $script :publishScriptPath 1> $null 6> $null } | Should - Throw ' *changed*'
358+
359+ $script :state.GalleryWrites | Should - Be 0
360+ $script :state.GitHubWrites | Should - Be 0
361+ }
362+
363+ It ' rejects supplied PR context without a positive identity before all writes' - ForEach @ (
364+ @ { Json = ' {}' }
365+ @ { Json = ' {"Number":0}' }
366+ @ { Json = ' {"Number":"unknown"}' }
367+ @ { Json = ' 42' }
368+ ) {
369+ $env: PSMODULE_PUBLISH_PSMODULE_INPUT_PullRequest = $Json
370+
371+ { & $script :publishScriptPath 1> $null 6> $null } | Should - Throw ' *pull request*'
372+
373+ $script :state.GalleryWrites | Should - Be 0
374+ $script :state.GitHubWrites | Should - Be 0
375+ }
376+
377+ It ' rejects a draft release before Gallery publication rather than reporting completed publication' {
378+ Set-PSModuleFixtureClaim - State $script :state - Claim $script :state.ExpectedClaim
379+ $script :state.Release = [pscustomobject ]@ {
380+ tag_name = ' v1.2.4' ; html_url = ' https://github.com/PSModule/TestModule/releases/tag/v1.2.4'
381+ prerelease = $false ; draft = $true ; body = ' Unpublished draft notes.' ; assets = @ ()
382+ }
383+
384+ { & $script :publishScriptPath 1> $null 6> $null } | Should - Throw ' *draft*'
385+
386+ $script :state.GalleryWrites | Should - Be 0
387+ $script :state.GitHubWrites | Should - Be 0
388+ }
330389}
0 commit comments