Skip to content

Commit 50f1642

Browse files
Cover matching-source release retry ownership conflicts
1 parent 925cd0b commit 50f1642

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎.github/actions/Release-PSModule/tests/Release-PSModule.WhatIf.Tests.ps1‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,53 @@ Describe 'Release-PSModule WhatIf' {
196196
Get-Content -Path $script:githubOutputPath | Should -Contain 'ReleaseTag=v1.2.3-preview.1'
197197
}
198198

199+
It 'prevents upload when an existing release footer conflicts with the <Conflict>' -ForEach @(
200+
@{ Conflict = 'repository'; OwnerRepository = 'OtherOwner/TestModule'; OwnerPullRequest = 42 }
201+
@{ Conflict = 'pull request'; OwnerRepository = 'PSModule/TestModule'; OwnerPullRequest = 99 }
202+
) {
203+
$env:PSMODULE_RELEASE_PSMODULE_INPUT_WhatIf = 'false'
204+
$env:PSMODULE_RELEASE_PSMODULE_INPUT_CommitSha = 'original-source-sha'
205+
$ownership = @{
206+
Repository = $OwnerRepository
207+
PullRequest = $OwnerPullRequest
208+
CommitSha = 'original-source-sha'
209+
} | ConvertTo-Json -Compress
210+
$encodedOwnership = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($ownership))
211+
$script:releaseFixture.Body = "Release notes`n`n<!-- PSModule.PrereleaseOwner:v1:$encodedOwnership -->"
212+
$exception = $null
213+
try {
214+
& $script:releaseScriptPath
215+
} catch {
216+
$exception = $_.Exception
217+
}
218+
219+
$uploads = @(Get-Content -LiteralPath $script:ghCallLogPath | Where-Object { $_ -like 'release upload *' })
220+
$uploads.Count | Should -Be 0
221+
$exception | Should -Not -BeNullOrEmpty
222+
$exception.Message | Should -Match 'ownership footer conflicts'
223+
$script:releaseFixture.SourceSha | Should -BeExactly 'original-source-sha'
224+
Get-Content -LiteralPath $script:githubOutputPath -Raw | Should -BeNullOrEmpty
225+
}
226+
227+
It 'resumes a missing upload when the recorded footer matches repository, PR, and source' {
228+
$env:PSMODULE_RELEASE_PSMODULE_INPUT_WhatIf = 'false'
229+
$env:PSMODULE_RELEASE_PSMODULE_INPUT_CommitSha = 'original-source-sha'
230+
$ownership = @{
231+
Repository = 'PSModule/TestModule'
232+
PullRequest = 42
233+
CommitSha = 'original-source-sha'
234+
} | ConvertTo-Json -Compress
235+
$encodedOwnership = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($ownership))
236+
$script:releaseFixture.Body = "Release notes`n`n<!-- PSModule.PrereleaseOwner:v1:$encodedOwnership -->"
237+
238+
{ & $script:releaseScriptPath } | Should -Not -Throw
239+
240+
$calls = Get-Content -LiteralPath $script:ghCallLogPath
241+
@($calls | Where-Object { $_ -like 'release upload *' }).Count | Should -Be 1
242+
$calls | Should -Not -Match 'release create|--clobber'
243+
Get-Content -LiteralPath $script:githubOutputPath | Should -Contain 'ReleaseTag=v1.2.3-preview.1'
244+
}
245+
199246
It 'refuses to resume a tag owned by a different commit without uploading' {
200247
$env:PSMODULE_RELEASE_PSMODULE_INPUT_WhatIf = 'false'
201248
$env:PSMODULE_RELEASE_PSMODULE_INPUT_CommitSha = 'original-source-sha'

0 commit comments

Comments
 (0)