From b23dc04547920849678c2a22046f89bd7e9eec8c Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Wed, 13 Sep 2023 16:21:11 -0400 Subject: [PATCH] add test --- src/code/V2ServerAPICalls.cs | 2 +- .../FindPSResourceV2Server.Tests.ps1 | 49 +++++++++++-------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/code/V2ServerAPICalls.cs b/src/code/V2ServerAPICalls.cs index 4a457b125..dfcb5092e 100644 --- a/src/code/V2ServerAPICalls.cs +++ b/src/code/V2ServerAPICalls.cs @@ -152,7 +152,7 @@ public override FindResults FindAll(bool includePrerelease, ResourceType type, o /// Find method which allows for searching for packages with tag from a repository and returns latest version for each. /// Examples: Search -Tag "JSON" -Repository PSGallery /// API call: - /// - Include prerelease: http://www.powershellgallery.com/api/v2/Search()?$filter=IsAbsoluteLatestVersion&searchTerm=tag:JSON&includePrerelease=true + /// - Include prerelease: https://www.powershellgallery.com/api/v2/Search()?includePrerelease=true&$filter=IsAbsoluteLatestVersion and substringof('PSModule', Tags) eq true and substringof('CrescendoBuilt', Tags) eq true&$orderby=Id desc&$inlinecount=allpages&$skip=0&$top=6000 /// public override FindResults FindTags(string[] tags, bool includePrerelease, ResourceType _type, out ErrorRecord errRecord) { diff --git a/test/FindPSResourceTests/FindPSResourceV2Server.Tests.ps1 b/test/FindPSResourceTests/FindPSResourceV2Server.Tests.ps1 index 6241c3172..0528a68f1 100644 --- a/test/FindPSResourceTests/FindPSResourceV2Server.Tests.ps1 +++ b/test/FindPSResourceTests/FindPSResourceV2Server.Tests.ps1 @@ -316,29 +316,38 @@ Describe 'Test HTTP Find-PSResource for V2 Server Protocol' -tags 'CI' { $err[0].FullyQualifiedErrorId | Should -BeExactly "PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource" } - # It "find all resources with specified tag given Tag property" { - # # FindTag() - # $foundTestModule = $False - # $foundTestScript = $False - # $tagToFind = "Tag2" - # $res = Find-PSResource -Tag $tagToFind -Repository $PSGalleryName - # foreach ($item in $res) { - # $item.Tags -contains $tagToFind | Should -Be $True + It "find all resources with specified tag given Tag property" { + # FindTag() + $foundTestModule = $False + $foundTestScript = $False + $tagToFind = "Tag2" + $res = Find-PSResource -Tag $tagToFind -Repository $PSGalleryName + foreach ($item in $res) { + $item.Tags -contains $tagToFind | Should -Be $True - # if ($item.Name -eq $testModuleName) - # { - # $foundTestModule = $True - # } + if ($item.Name -eq $testModuleName) + { + $foundTestModule = $True + } - # if ($item.Name -eq $testScriptName) - # { - # $foundTestScript = $True - # } - # } + if ($item.Name -eq $testScriptName) + { + $foundTestScript = $True + } + } - # $foundTestModule | Should -Be $True - # $foundTestScript | Should -Be $True - # } + $foundTestModule | Should -Be $True + $foundTestScript | Should -Be $True + } + + It "find all resources with specified tag given Tag property, with and without Prerelease property" { + $tagToFind = "MyPSTag" + $res = Find-PSResource -Tag $tagToFind -Repository $PSGalleryName + $res | Should -HaveCount 1 + + $res = Find-PSResource -Tag $tagToFind -Repository $PSGalleryName -Prerelease + $res | Should -HaveCount 2 + } It "find resource given CommandName" { $res = Find-PSResource -CommandName $commandName -Repository $PSGalleryName