Skip to content

Commit c1e94bb

Browse files
Copilotalerickson
andcommitted
Improve test to use BeforeEach installed module
Co-authored-by: alerickson <[email protected]>
1 parent 26936b2 commit c1e94bb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/UninstallPSResourceTests/UninstallPSResource.Tests.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,18 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' {
236236
}
237237

238238
It "Write warning when using -Prerelease flag with only stable versions installed" {
239-
# Install a stable version
240-
Install-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $PSGalleryName -TrustRepository
239+
# BeforeEach already installs a stable version of $testModuleName (5.0.0.0)
240+
# Verify it's installed
241+
$pkg = Get-InstalledPSResource $testModuleName
242+
$pkg | Should -Not -BeNullOrEmpty
241243

242244
# Try to uninstall with -Prerelease flag, should show warning
243245
Uninstall-PSResource -Name $testModuleName -Prerelease -SkipDependencyCheck -WarningVariable warn -WarningAction SilentlyContinue
244246

245-
# Module should still be present
246-
$res = Get-InstalledPSResource -Name $testModuleName -Version "5.0.0.0"
247+
# Module should still be present since no prerelease versions were found
248+
$res = Get-InstalledPSResource -Name $testModuleName
249+
$res | Should -Not -BeNullOrEmpty
247250
$res.Name | Should -Be $testModuleName
248-
$res.Version | Should -Be "5.0.0.0"
249251

250252
# Warning should have been written
251253
$warn.Count | Should -Be 1

0 commit comments

Comments
 (0)