Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
anamnavi committed Sep 13, 2023
1 parent edef53e commit b23dc04
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/code/V2ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// </summary>
public override FindResults FindTags(string[] tags, bool includePrerelease, ResourceType _type, out ErrorRecord errRecord)
{
Expand Down
49 changes: 29 additions & 20 deletions test/FindPSResourceTests/FindPSResourceV2Server.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b23dc04

Please sign in to comment.