Skip to content

Commit 3758ffb

Browse files
committed
Add test
1 parent f37d089 commit 3758ffb

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
1313
$testModuleName = "test_module"
1414
$testModuleName2 = "test_module2"
1515
$testModuleName3 = "TestModule99"
16+
$testModuleName4 = "TestModulePrerelease"
1617
$PackageManagement = "PackageManagement"
1718
Get-NewPSResourceRepositoryFile
1819
Get-PSResourceRepository
1920
}
2021

2122
AfterEach {
22-
Uninstall-PSResource "test_module", "TestModule99", "TestModuleWithLicense", "test_module2", "test_script" -Version "*" -ErrorAction SilentlyContinue -SkipDependencyCheck
23+
Uninstall-PSResource "test_module", "TestModule99", "TestModuleWithLicense", "test_module2", "test_script", "TestModulePrerelease" -Version "*" -ErrorAction SilentlyContinue -SkipDependencyCheck
2324
}
2425

2526
AfterAll {
@@ -210,6 +211,20 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
210211
$isPkgUpdated | Should -Be $true
211212
}
212213

214+
It "Update prerelease version to next version when prerelease label is only differing factor between versions" {
215+
# $testModuleName4 (TestModulePrerelease) has versions: 0.0.4-beta, 0.0.4. Updating should respect prerelease label
216+
Install-PSResource -Name $testModuleName4 -Version "0.0.4-beta" -Repository $PSGalleryName -TrustRepository
217+
$res = Get-InstalledPSResource -Name $testModuleName4
218+
$res.Name | Should -Be $testModuleName4
219+
$res.Version | Should -Contain "0.0.4"
220+
$res.Prerelease | Should -Be "beta"
221+
222+
Update-PSResource -Name $testModuleName4 -Repository $PSGalleryName -TrustRepository
223+
$res2 = Get-InstalledPSResource -Name $testModuleName4
224+
$res2.Version | Should -Contain "0.0.4"
225+
$res2.Prerelease | Should -BeNullOrEmpty
226+
}
227+
213228
# Windows only
214229
It "update resource under CurrentUser scope" -skip:(!($IsWindows -and (Test-IsAdmin))) {
215230
# TODO: perhaps also install TestModule with the highest version (the one above 1.2.0.0) to the AllUsers path too

0 commit comments

Comments
 (0)