From 36a736bc7e2602c275bb30827284a72f2a25f1d8 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 21 Nov 2024 14:05:37 -0800 Subject: [PATCH] (#3565) Remove query string from Pester tests 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. --- .../features/CredentialProvider.Tests.ps1 | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/pester-tests/features/CredentialProvider.Tests.ps1 b/tests/pester-tests/features/CredentialProvider.Tests.ps1 index 2792f2564..7b5e5d754 100644 --- a/tests/pester-tests/features/CredentialProvider.Tests.ps1 +++ b/tests/pester-tests/features/CredentialProvider.Tests.ps1 @@ -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 } ) { @@ -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 } } }