Skip to content

Commit 8b5b509

Browse files
committed
update tests
1 parent 1748fbd commit 8b5b509

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

test/FindPSResourceTests/FindPSResourceV2Server.Tests.ps1

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,17 +458,39 @@ Describe 'Test HTTP Find-PSResource for V2 Server Protocol' -tags 'ManualValidat
458458
$duplicatePkgsFound | Should -BeFalse
459459
}
460460

461-
It "find should return an unlisted module when it was requested explicitly by full name and version (i.e no wildcards)" {
462-
# 'test_unlisted' is an unlisted package
463-
$res = Find-PSResource -Name "test_unlisted" -Version "0.0.1" -Repository $PSGalleryName
461+
It "find should not return a module that has all unlisted versions, given full name and no version (i.e non wildcard name)" {
462+
# FindName() scenario
463+
# 'test_completelyunlisted' only has version 0.0.1, which is unlisted
464+
$res = Find-PSResource -Name "test_completelyunlisted" -Repository $PSGalleryName
465+
$res | Should -BeNullOrEmpty
466+
$err.Count | Should -BeGreaterThan 0
467+
$err[0].FullyQualifiedErrorId | Should -BeExactly "PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
468+
$res | Should -BeNullOrEmpty
469+
}
470+
471+
It "find should return a module version even if all versions are unlisted, given full name and version (i.e non wildcard name)" {
472+
# FindVersion() scenario
473+
# test_completelyunlisted has 1 version, 0.0.1, which is unlisted
474+
$res = Find-PSResource -Name "test_completelyunlisted" -Version "0.0.1" -Repository $PSGalleryName
464475
$res | Should -Not -BeNullOrEmpty
465476
$res.Version | Should -Be "0.0.1"
466477
}
467478

479+
It "find should return an unlisted module, where the module has a mix of listed and unlisted versions, given full name and version (i.e non wildcard name)" {
480+
# FindVersion scenario
481+
# 'test_unlisted' version 0.0.3 is unlisted
482+
$res = Find-PSResource -Name "test_unlisted" -Version "0.0.3" -Repository $PSGalleryName
483+
$res | Should -Not -BeNullOrEmpty
484+
$res.Version | Should -Be "0.0.3"
485+
}
486+
468487
It "find should not return an unlisted module with it was requested with wildcards in the name" {
469-
# 'test_unlisted' is an unlisted package whereas 'test_notunlisted' is listed
488+
# FindNameGlobbing() scenario
489+
# 'test_completelyunlisted' has all unlisted versions -> should not be returned
490+
# whereas 'test_unlisted' has a listed verison and 'test_notunlisted' has all listed versions -> should be returned
470491
$res = Find-PSResource -Name "test_*unlisted" -Repository $PSGalleryName
471-
$res.Count | Should -Be 1
472-
$res[0].Name | Should -Be "test_notunlisted"
492+
$res.Count | Should -Be 2
493+
$res.Name | Should -Contain 'test_unlisted'
494+
$res.Name | Should -Contain 'test_notunlisted'
473495
}
474496
}

test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,12 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' {
574574
$res.Version | Should -Be $version
575575
}
576576

577-
It "Install resource that is unlisted" {
578-
# 'test_unlisted' is an unlisted package
577+
It "Install resource that is unlisted" {
578+
# InstallVersion scenario
579+
# 'test_unlisted' version 0.0.3 is unlisted
579580
$moduleName = 'test_unlisted'
580-
$version = '0.0.1'
581-
Install-PSResource -Name $moduleName -Repository $PSGalleryName -TrustRepository
581+
$version = '0.0.3'
582+
Install-PSResource -Name $moduleName -Version $version -Repository $PSGalleryName -TrustRepository
582583
$res = Get-InstalledPSResource $moduleName
583584
$res | Should -Not -BeNullOrEmpty
584585
$res.Version | Should -Be $version

0 commit comments

Comments
 (0)