diff --git a/test/SavePSResource.Tests.ps1 b/test/SavePSResource.Tests.ps1 index 66858ce6d..067baecbb 100644 --- a/test/SavePSResource.Tests.ps1 +++ b/test/SavePSResource.Tests.ps1 @@ -52,9 +52,11 @@ Describe 'Test Save-PSResource for PSResources' { } It "Should not save resource given nonexistant name" { - Save-PSResource -Name NonExistentModule -Repository $TestGalleryName -Path $SaveDir + Save-PSResource -Name NonExistentModule -Repository $TestGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq "NonExistentModule" $pkgDir.Name | Should -BeNullOrEmpty + $err.Count | Should -Not -Be 0 + $err[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" } It "Not Save module with Name containing wildcard" { @@ -102,9 +104,11 @@ Describe 'Test Save-PSResource for PSResources' { ) { param($Version, $Description) - Save-PSResource -Name $testModuleName2 -Version $Version -Repository $TestGalleryName -Path $SaveDir + Save-PSResource -Name $testModuleName2 -Version $Version -Repository $TestGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName2 $pkgDir | Should -BeNullOrEmpty + $err.Count | Should -Not -Be 0 + $err[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" } It "Save resource when given Name, Version '*', should install the latest version" { diff --git a/test/UninstallPSResource.Tests.ps1 b/test/UninstallPSResource.Tests.ps1 index 3c4bcdc66..eba8cfbc5 100644 --- a/test/UninstallPSResource.Tests.ps1 +++ b/test/UninstallPSResource.Tests.ps1 @@ -43,15 +43,27 @@ Describe 'Test Uninstall-PSResource for Modules' { } It "Uninstall a specific script by name" { - $null = Install-PSResource Test-RPC -Repository $TestGalleryName -TrustRepository -WarningAction SilentlyContinue + $null = Install-PSResource "test_script" -Repository $TestGalleryName -TrustRepository + $res = Get-PSResource -Name "test_script" + $res.Name | Should -Be "test_script" - Uninstall-PSResource -name Test-RPC + Uninstall-PSResource -name "test_script" + $res = Get-PSResource -Name "test_script" + $res | Should -BeNullOrEmpty } It "Uninstall a list of scripts by name" { - $null = Install-PSResource adsql, airoute -Repository $TestGalleryName -TrustRepository -WarningAction SilentlyContinue - - Uninstall-PSResource -Name adsql, airoute + $null = Install-PSResource "test_script", "TestTestScript" -Repository $TestGalleryName -TrustRepository + $res = Get-PSResource -Name "test_script" + $res2 = Get-PSResource -Name "TestTestScript" + $res.Name | Should -Be "test_script" + $res2.Name | Should -Be "TestTestScript" + + Uninstall-PSResource -Name "test_script", "TestTestScript" + $res = Get-PSResource -Name "test_script" + $res2 = Get-PSResource -Name "TestTestScript" + $res | Should -BeNullOrEmpty + $res2 | Should -BeNullOrEmpty } It "Uninstall a module when given name and specifying all versions" {