Skip to content

Commit 33efec4

Browse files
Reproduce completed historical tags with numeric prefixes
(cherry picked from commit 254cebc)
1 parent e2e282a commit 33efec4

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

‎.github/actions/Resolve-PSModuleVersion/tests/Resolve-PSModuleVersion.Recovery.Tests.ps1‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,40 @@ Describe 'Gallery-only version selection requires original ownership proof' {
272272
$script:state.Calls | Should -Not -Contain 'release-read:release-1.2.4'
273273
}
274274

275+
It 'uses a completed historical prefix <HistoricalPrefix> under current prefix <CurrentPrefix>' -ForEach @(
276+
@{ HistoricalPrefix = 'release2-'; CurrentPrefix = 'release2-' }
277+
@{ HistoricalPrefix = 'release2-'; CurrentPrefix = 'release-' }
278+
@{ HistoricalPrefix = 'release2'; CurrentPrefix = 'release2' }
279+
) {
280+
$tag = "${HistoricalPrefix}1.2.4"
281+
$script:state.Record.Reference.ref = "refs/tags/$tag"
282+
$script:state.Record.Annotation.tag = $tag
283+
$script:state.Record.Annotation.object.sha = '2222222222222222222222222222222222222222'
284+
$script:state.Record.Annotation.message = 'Completed legacy publication.'
285+
$script:state.Record.Release = [pscustomobject]@{
286+
tag_name = $tag; prerelease = $false; draft = $false
287+
assets = @([pscustomobject]@{ name = 'TestModule-1.2.4.zip'; state = 'uploaded' })
288+
}
289+
$script:parameters.Configuration.VersionPrefix = $CurrentPrefix
290+
291+
(Get-ResolvedModuleVersion @script:parameters).ToString() | Should -BeExactly "${CurrentPrefix}1.2.5"
292+
293+
$script:state.Calls | Should -Contain "release-read:$tag"
294+
}
295+
296+
It 'does not infer a complete baseline from a numeric tag suffix without matching module-version assets' {
297+
$script:state.Record.Reference.ref = 'refs/tags/v11.2.4'
298+
$script:state.Record.Annotation.tag = 'v11.2.4'
299+
$script:state.Record.Annotation.object.sha = '2222222222222222222222222222222222222222'
300+
$script:state.Record.Annotation.message = 'A different completed version.'
301+
$script:state.Record.Release = [pscustomobject]@{
302+
tag_name = 'v11.2.4'; prerelease = $false; draft = $false
303+
assets = @([pscustomobject]@{ name = 'TestModule-11.2.4.zip'; state = 'uploaded' })
304+
}
305+
306+
{ Get-ResolvedModuleVersion @script:parameters } | Should -Throw '*source/artifact recovery context*'
307+
}
308+
275309
It 'rejects ambiguous completed historical baseline tags instead of choosing a prefix' {
276310
$script:state.Record.Annotation.object.sha = '2222222222222222222222222222222222222222'
277311
$script:state.Record.Annotation.message = 'Completed legacy tag.'

0 commit comments

Comments
 (0)