@@ -12,7 +12,6 @@ Describe 'Test HTTP Find-PSResource for V2 Server Protocol' -tags 'CI' {
1212 BeforeAll{
1313 $PSGalleryName = Get-PSGalleryName
1414 $testModuleName = " test_module"
15- $testModuleNameWithUnlistedVersion = " test_module10"
1615 $testScriptName = " test_script"
1716 $commandName = " Get-TargetResource"
1817 $dscResourceName = " SystemLocale"
@@ -413,11 +412,40 @@ Describe 'Test HTTP Find-PSResource for V2 Server Protocol' -tags 'CI' {
413412 $err.Count | Should - Be 0
414413 }
415414
416- It " should not find and write error when finding package version that is unlisted" {
417- $res = Find-PSResource - Name $testModuleNameWithUnlistedVersion - Version " 1.0.0.0" - Repository $PSGalleryName - ErrorVariable err - ErrorAction SilentlyContinue
418- $res | Should - HaveCount 0
419- $err | Should - HaveCount 1
415+ It " find should not return a module that has all unlisted versions, given full name and no version (i.e non wildcard name)" {
416+ # FindName() scenario
417+ # 'test_completelyunlisted' only has version 0.0.1, which is unlisted
418+ $res = Find-PSResource - Name " test_completelyunlisted" - Repository $PSGalleryName
419+ $res | Should - BeNullOrEmpty
420+ $err.Count | Should - BeGreaterThan 0
420421 $err [0 ].FullyQualifiedErrorId | Should - BeExactly " PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
422+ $res | Should - BeNullOrEmpty
423+ }
424+
425+ It " find should return a module version even if all versions are unlisted, given full name and version (i.e non wildcard name)" {
426+ # FindVersion() scenario
427+ # test_completelyunlisted has 1 version, 0.0.1, which is unlisted
428+ $res = Find-PSResource - Name " test_completelyunlisted" - Version " 0.0.1" - Repository $PSGalleryName
429+ $res | Should -Not - BeNullOrEmpty
430+ $res.Version | Should - Be " 0.0.1"
431+ }
432+
433+ 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)" {
434+ # FindVersion scenario
435+ # 'test_unlisted' version 0.0.3 is unlisted
436+ $res = Find-PSResource - Name " test_unlisted" - Version " 0.0.3" - Repository $PSGalleryName
437+ $res | Should -Not - BeNullOrEmpty
438+ $res.Version | Should - Be " 0.0.3"
439+ }
440+
441+ It " find should not return an unlisted module with it was requested with wildcards in the name" {
442+ # FindNameGlobbing() scenario
443+ # 'test_completelyunlisted' has all unlisted versions -> should not be returned
444+ # whereas 'test_unlisted' has a listed verison and 'test_notunlisted' has all listed versions -> should be returned
445+ $res = Find-PSResource - Name " test_*unlisted" - Repository $PSGalleryName
446+ $res.Count | Should - Be 2
447+ $res.Name | Should - Contain ' test_unlisted'
448+ $res.Name | Should - Contain ' test_notunlisted'
421449 }
422450}
423451
@@ -457,40 +485,4 @@ Describe 'Test HTTP Find-PSResource for V2 Server Protocol' -tags 'ManualValidat
457485
458486 $duplicatePkgsFound | Should - BeFalse
459487 }
460-
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
475- $res | Should -Not - BeNullOrEmpty
476- $res.Version | Should - Be " 0.0.1"
477- }
478-
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-
487- It " find should not return an unlisted module with it was requested with wildcards in the name" {
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
491- $res = Find-PSResource - Name " test_*unlisted" - Repository $PSGalleryName
492- $res.Count | Should - Be 2
493- $res.Name | Should - Contain ' test_unlisted'
494- $res.Name | Should - Contain ' test_notunlisted'
495- }
496488}
0 commit comments