@@ -128,7 +128,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
128128
129129 It " find multiple resources from all repositories where it exists where package Name contains wildcard (without -Repository specified)" {
130130 $res = Find-PSResource - Name " test_module*" - ErrorVariable err - ErrorAction SilentlyContinue
131- $res | Should - HaveCount 12
131+ $res.Count | Should - BeGreaterOrEqual 1
132132 $err | Should - HaveCount 0
133133
134134 $pkgFoundinLocalRepo = $false
@@ -309,7 +309,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
309309 # Package with Tag "" exists in the following repositories: PSGallery, NuGetGallery, and localRepo
310310 $res = Find-PSResource - Tag $tag1 - ErrorVariable err - ErrorAction SilentlyContinue
311311 $err | Should - HaveCount 0
312- $res.Count | Should - BeGreaterOrEqual 5
312+ $res.Count | Should - BeGreaterOrEqual 1
313313
314314 $pkg1 = $res [0 ]
315315 $pkg1.Name | Should - Be $testModuleName
@@ -338,7 +338,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
338338 # Package with tag "Tag-Required-Script1-2.5" exists in the following repositories: PSGallery, NuGetGallery
339339 $res = Find-PSResource - Tag $tag2 - ErrorVariable err - ErrorAction SilentlyContinue
340340 $err | Should - HaveCount 0
341- $res.Count | Should - BeGreaterOrEqual 3
341+ $res.Count | Should - BeGreaterOrEqual 1
342342
343343 $pkg1 = $res [0 ]
344344 $pkg1.Name | Should - Be " test_script"
@@ -379,7 +379,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
379379 $err | Should - HaveCount 1
380380 $err [0 ].FullyQualifiedErrorId | Should - BeExactly " WildcardsUnsupportedForTag,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
381381
382- $res.Count | Should - BeGreaterOrEqual 3
382+ $res.Count | Should - BeGreaterOrEqual 1
383383 $pkg1 = $res [0 ]
384384 $pkg1.Name | Should - Be " test_script"
385385 $pkg1.Repository | Should - Be $PSGalleryName
@@ -397,7 +397,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
397397 # Package with Tag "CommandsAndResource" exists in the following repositories: PSGallery, NuGetGallery, localRepo
398398 $res = Find-PSResource - Tag $tag1 - Repository " *Gallery" - ErrorVariable err - ErrorAction SilentlyContinue
399399 $err | Should - HaveCount 0
400- $res.Count | Should - BeGreaterOrEqual 4
400+ $res.Count | Should - BeGreaterOrEqual 1
401401
402402 # Note Find-PSResource -Tag returns package Ids in desc order
403403 $pkg1 = $res [0 ]
@@ -431,7 +431,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
431431
432432 It " find resource from single specific repository (-Repository with single non-wildcard value)" {
433433 $res = Find-PSResource - Tag $tag2 - Repository $PSGalleryName
434- $res.Count | Should - BeGreaterOrEqual 2
434+ $res.Count | Should - BeGreaterOrEqual 1
435435 $pkg1 = $res [0 ]
436436 $pkg1.Name | Should - Be " test_script"
437437 $pkg1.Repository | Should - Be $PSGalleryName
@@ -450,7 +450,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
450450
451451 It " find resource from all repositories where it exists (-Repository with multiple non-wildcard values)" {
452452 $res = Find-PSResource - Tag $tag2 - Repository $PSGalleryName , $NuGetGalleryName
453- $res.Count | Should - BeGreaterOrEqual 3
453+ $res.Count | Should - BeGreaterOrEqual 1
454454
455455 $pkg1 = $res [0 ]
456456 $pkg1.Name | Should - Be " test_script"
@@ -469,7 +469,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
469469 # Package with Tag "Tag-TestMyLocalScript-1.0.0.0" exists in the following repositories: PSGallery
470470 $tagForPkgOnPSGallery = " Tag-TestMyLocalScript-1.0.0.0"
471471 $res = Find-PSResource - Tag $tagForPkgOnPSGallery - Repository $PSGalleryName , $NuGetGalleryName - ErrorVariable err - ErrorAction SilentlyContinue
472- $res.Count | Should - BeGreaterOrEqual 2
472+ $res.Count | Should - BeGreaterOrEqual 1
473473 $err | Should - HaveCount 1
474474
475475 $pkg1 = $res [0 ]
@@ -488,7 +488,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
488488 # $cmdNameToSearch = "Get-TargetResource"
489489 $res = Find-PSResource - CommandName $cmdName - ErrorVariable err - ErrorAction SilentlyContinue
490490 $err | Should - HaveCount 0
491- $res.Count | Should - BeGreaterOrEqual 9
491+ $res.Count | Should - BeGreaterOrEqual 1
492492 $pkgFoundFromLocalRepo = $false
493493 $pkgFoundFromPSGallery = $false
494494
@@ -531,6 +531,60 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
531531 $err [0 ].FullyQualifiedErrorId | Should - BeExactly " WildcardsUnsupportedForCommandNameorDSCResourceName,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
532532 }
533533
534+ It " not find resource and discard CommandName entry containing wildcard, but search for other non-wildcard CommandName entries (without -Repository specified)" {
535+ $res = Find-PSResource - CommandName $cmdName , " myCommandName*" - ErrorVariable err - ErrorAction SilentlyContinue
536+ $err | Should - HaveCount 1
537+ $err [0 ].FullyQualifiedErrorId | Should - BeExactly " WildcardsUnsupportedForCommandNameorDSCResourceName,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
538+
539+ $res.Count | Should - BeGreaterOrEqual 1
540+ $pkgFoundFromLocalRepo = $false
541+ $pkgFoundFromPSGallery = $false
542+
543+ foreach ($pkg in $res )
544+ {
545+ if ($pkg.ParentResource.Repository -eq $localRepoName )
546+ {
547+ $pkgFoundFromLocalRepo = $true
548+ }
549+ elseif ($pkg.ParentResource.Repository -eq $PSGalleryName )
550+ {
551+ $pkgFoundFromPSGallery = $true
552+ }
553+ }
554+
555+ $pkg.Names | Should - Be $cmdName
556+ $pkg.ParentResource.Includes.Command | Should - Contain $cmdName
557+ $pkgFoundFromLocalRepo | Should - BeTrue
558+ $pkgFoundFromPSGallery | Should - BeTrue
559+ }
560+
561+ It " find resources from all pattern matching repositories where it exists (-Repository with wildcard)" {
562+ # Package with CommandName "Get-TargetResource" exists in the following repositories: PSGallery, localRepo
563+ $res = Find-PSResource - CommandName $cmdName - Repository " *Gallery" - ErrorVariable err - ErrorAction SilentlyContinue
564+ $err | Should - HaveCount 0
565+ $res.Count | Should - BeGreaterOrEqual 1
566+
567+ $pkgFoundFromLocalRepo = $false
568+ $pkgFoundFromPSGallery = $false
569+
570+ foreach ($pkg in $res )
571+ {
572+ if ($pkg.ParentResource.Repository -eq $localRepoName )
573+ {
574+ $pkgFoundFromLocalRepo = $true
575+ }
576+ elseif ($pkg.ParentResource.Repository -eq $PSGalleryName )
577+ {
578+ $pkgFoundFromPSGallery = $true
579+ }
580+ }
581+
582+ $pkg.Names | Should - Be $cmdName
583+ $pkg.ParentResource.Includes.Command | Should - Contain $cmdName
584+ $pkgFoundFromLocalRepo | Should - BeFalse
585+ $pkgFoundFromPSGallery | Should - BeTrue
586+ }
587+
534588 It " should not allow for repository name with wildcard and non-wildcard command name specified in same command run" {
535589 {Find-PSResource - CommandName $cmdName - Repository " *Gallery" , $localRepoName } | Should - Throw - ErrorId " RepositoryNamesWithWildcardsAndNonWildcardUnsupported,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
536590 }
@@ -563,6 +617,31 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
563617 $err [0 ].FullyQualifiedErrorId | Should - BeExactly " FindCmdOrDSCNamesPackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
564618 }
565619
620+ It " find resource given CommandName from all repositories where it exists (-Repository with multiple non-wildcard values)" {
621+ $res = Find-PSResource - CommandName $cmdName - Repository $PSGalleryName , $localRepoName
622+ $res.Count | Should - BeGreaterOrEqual 1
623+
624+ $pkgFoundFromLocalRepo = $false
625+ $pkgFoundFromPSGallery = $false
626+
627+ foreach ($pkg in $res )
628+ {
629+ if ($pkg.ParentResource.Repository -eq $localRepoName )
630+ {
631+ $pkgFoundFromLocalRepo = $true
632+ }
633+ elseif ($pkg.ParentResource.Repository -eq $PSGalleryName )
634+ {
635+ $pkgFoundFromPSGallery = $true
636+ }
637+ }
638+
639+ $pkg.Names | Should - Be $cmdName
640+ $pkg.ParentResource.Includes.Command | Should - Contain $cmdName
641+ $pkgFoundFromLocalRepo | Should - BeTrue
642+ $pkgFoundFromPSGallery | Should - BeTrue
643+ }
644+
566645 It " find resource given CommandName from all repositories where it exists and write errors for those it does not exist from (-Repository with multiple non-wildcard values)" {
567646 # Package with Command "Get-MyCommand" exists in the following repositories: localRepo
568647 $res = Find-PSResource - CommandName $cmdName2 - Repository $PSGalleryName , $localRepoName - ErrorVariable err - ErrorAction SilentlyContinue
@@ -629,7 +708,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
629708 It " find resource that has DSCResourceName specified from all repositories where it exists and not write errors where it does not exist (without -Repository specified)" {
630709 $res = Find-PSResource - DscResourceName $dscName - ErrorVariable err - ErrorAction SilentlyContinue
631710 $err | Should - HaveCount 0
632- $res.Count | Should - BeGreaterOrEqual 2
711+ $res.Count | Should - BeGreaterOrEqual 1
633712 $pkgFoundFromLocalRepo = $false
634713 $pkgFoundFromPSGallery = $false
635714
@@ -677,7 +756,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
677756 $err | Should - HaveCount 1
678757 $err [0 ].FullyQualifiedErrorId | Should - BeExactly " WildcardsUnsupportedForCommandNameorDSCResourceName,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
679758
680- $res.Count | Should - BeGreaterOrEqual 2
759+ $res.Count | Should - BeGreaterOrEqual 1
681760 $pkgFoundFromLocalRepo = $false
682761 $pkgFoundFromPSGallery = $false
683762
@@ -703,7 +782,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
703782 # Package with DSCResourceName "SystemLocale" exists in the following repositories: PSGallery, localRepo
704783 $res = Find-PSResource - DscResourceName $dscName - Repository " *Gallery" - ErrorVariable err - ErrorAction SilentlyContinue
705784 $err | Should - HaveCount 0
706- $res.Count | Should - BeGreaterOrEqual 2
785+ $res.Count | Should - BeGreaterOrEqual 1
707786
708787 $pkgFoundFromLocalRepo = $false
709788 $pkgFoundFromPSGallery = $false
@@ -761,7 +840,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
761840
762841 It " find resource given DSCResourceName from all repositories where it exists (-Repository with multiple non-wildcard values)" {
763842 $res = Find-PSResource - DscResourceName $dscName - Repository $PSGalleryName , $localRepoName
764- $res.Count | Should - BeGreaterOrEqual 3
843+ $res.Count | Should - BeGreaterOrEqual 1
765844
766845 $pkgFoundFromLocalRepo = $false
767846 $pkgFoundFromPSGallery = $false
0 commit comments