Skip to content

Commit

Permalink
Merge pull request #3576 from corbob/minor-test-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm authored Nov 29, 2024
2 parents 4f5bd1d + e852aff commit b9ef43f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/pester-tests/commands/choco-push.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ Describe 'choco push nuget <_> repository' -Tag Chocolatey, PushCommand -Skip:($

if ($UseConfig) {
$null = Invoke-Choco apikey add --source $RepositoryToUse$RepositoryEndpoint --api-key $ApiKey
# Add the Nuget source so that the push doesn't prompt for credentials.
# See https://github.com/chocolatey/choco/issues/2026#issuecomment-2423828013
$null = Invoke-Choco source add --name temporary-nuget --source $RepositoryToUse$RepositoryEndpoint --user $env:NUGET_SOURCE_USERNAME --password $env:NUGET_SOURCE_PASSWORD
# Ensure the key is null (should always be, but scoping can be wonky)
$KeyParameter = $null
} else {
Expand Down
9 changes: 8 additions & 1 deletion tests/pester-tests/features/UserAgent.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ Describe "Chocolatey User Agent" -Tag Chocolatey, UserAgent {

$userAgent = $matches['UserAgent']

$userAgent -match 'Chocolatey Command Line/(?<Version>[a-z0-9.-]+) ([a-z ]+/(<?LicensedVersion>[a-z0-9.-]+) )?\((?<RootProcess>[^,)]+)(?:, (?<ParentProcess>[^)]+))?\) via NuGet Client' |
$userAgent -match 'Chocolatey Command Line/(?<Version>[a-z0-9.-]+) ([a-z ]+/(?<LicensedVersion>[a-z0-9.-]+) )?\((?<RootProcess>[^,)]+)(?:, (?<ParentProcess>[^)]+))?\) via NuGet Client' |
Should -BeTrue -Because "the user agent string should contain the choco.exe version, the licensed extension version if any, and any parent processes. $logLine"

$matches['Version'] | Should -Be $ChocolateyVersion -Because "the user agent string should contain the currently running Chocolatey version. $logLine"

if (Test-PackageIsEqualOrHigher -PackageName 'chocolatey.extension' -Version '6.3.0-alpha') {
# We are not asserting the Licensed Extension version here as the Chocolatey package version often
# mismatches the assembly version.
$matches['LicensedVersion'] | Should -Not -BeNullOrEmpty -Because "Chocolatey Licensed Extension is installed and should be in the user agent. $logLine"
}

$filteredProcesses = @($Processes | Where-Object { $_ -notin $ExcludedProcesses })

if ($filteredProcesses.Count -gt 1) {
Expand Down

0 comments on commit b9ef43f

Please sign in to comment.