Skip to content

Commit

Permalink
(chocolatey#3565) Remove query string from Pester tests
Browse files Browse the repository at this point in the history
The query string used by some commands seems to be ever so slightly
different depending on where they are run. This removes the query string
from the tests as these tests are not concerned with the entire message,
just the initial part of the message.
  • Loading branch information
corbob committed Nov 21, 2024
1 parent 1353106 commit 36a736b
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions tests/pester-tests/features/CredentialProvider.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
Describe 'Ensuring credentials do not bleed from configured sources' -Tag CredentialProvider -ForEach @(
@{
Command = 'info'
QueryString = "/Packages()?`$filter=(tolower(Id)%20eq%20'chocolatey-compatibility.extension')%20and%20IsLatestVersion&semVerLevel=2.0.0"
ExitCode = 0
}
@{
Command = 'install'
QueryString = "/Packages()?`$filter=(tolower(Id)%20eq%20'chocolatey-compatibility.extension')%20and%20IsLatestVersion&semVerLevel=2.0.0"
ExitCode = 1
}
@{
Command = 'outdated'
# The QueryString here is emitted for each package installed. The chocolatey package is the only one we can be sure is present.
QueryString = "/Packages()?`$filter=tolower(Id)%20eq%20'chocolatey'&semVerLevel=2.0.0"
ExitCode = 0
}
@{
Command = 'search'
#
QueryString = "/Packages()?`$filter=((((Id%20ne%20null)%20and%20substringof('chocolatey-compatibility.extension',tolower(Id)))%20or%20((Description%20ne%20null)%20and%20substringof('chocolatey-compatibility.extension',tolower(Description))))%20or%20((Tags%20ne%20null)%20and%20substringof('%20chocolatey-compatibility.extension%20',tolower(Tags))))%20and%20IsLatestVersion&`$orderby=Id&`$skip=0&`$top=30&semVerLevel=2.0.0"
ExitCode = 1
}
@{
Command = 'upgrade'
QueryString = "/Packages()?`$filter=(tolower(Id)%20eq%20'chocolatey-compatibility.extension')%20and%20IsLatestVersion&semVerLevel=2.0.0"
ExitCode = 1
}
@{
Command = 'download'
QueryString = "/Packages()?`$filter=(tolower(Id)%20eq%20'chocolatey-compatibility.extension')%20and%20IsLatestVersion&semVerLevel=2.0.0"
ExitCode = 1
}
) {
Expand Down Expand Up @@ -63,7 +55,8 @@
}

It 'Outputs error message' {
$Output.Lines | Should -Contain "Failed to fetch results from V2 feed at '$($SetupSource.Url.Trim('/'))$QueryString' with following message : Response status code does not indicate success: 401 (Unauthorized)." -Because $Output.String
$FilteredOutput = $Output.Lines -match "Failed to fetch results from V2 feed at '$($SetupSource.Url.Trim('/'))"
$FilteredOutput.Count | Should -BeGreaterOrEqual 1 -Because $Output.String
}
}
}

0 comments on commit 36a736b

Please sign in to comment.