@@ -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}
0 commit comments