Skip to content

Commit

Permalink
(chocolatey#3224) Update version check tests
Browse files Browse the repository at this point in the history
Previously the version check would assume that all of the output from
`choco --version` should be considered as part of the version. However,
if the licensed assembly reports it's not valid, it does so very early
in the process, and outputs on this command before the version is
output. In order to work around this, the command to get the running
version should get just the very last line it's returned.
  • Loading branch information
corbob committed Jun 27, 2023
1 parent d871a22 commit 580f86c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/helpers/common/Chocolatey/Get-ChocolateyVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[CmdletBinding()]
param()
if (-not $script:runningVersion) {
[NuGet.Versioning.NuGetVersion]$script:runningVersion = ((Invoke-Choco --version).Lines | Where-Object { $_ -NotMatch "please upgrade" }) -join '`r`n'
[NuGet.Versioning.NuGetVersion]$script:runningVersion = (Invoke-Choco --version).Lines | Where-Object { $_ -Match "^\d+\.[\d\.]+" } | Select-Object -First 1
}

$script:runningVersion
Expand Down

0 comments on commit 580f86c

Please sign in to comment.