Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions test/SavePSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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" {
Expand Down
22 changes: 17 additions & 5 deletions test/UninstallPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down