@@ -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