diff --git a/tests/chocolatey-tests/choco-upgrade.Tests.ps1 b/tests/chocolatey-tests/choco-upgrade.Tests.ps1 index 269ee5f0de..aca4f1f344 100644 --- a/tests/chocolatey-tests/choco-upgrade.Tests.ps1 +++ b/tests/chocolatey-tests/choco-upgrade.Tests.ps1 @@ -119,4 +119,86 @@ Describe "choco upgrade" -Tag Chocolatey, UpgradeCommand { $Output.Lines | Should -Contain "Chocolatey upgraded 1/1 packages." -Because $Output.String } } + + Context "Upgrading packages while remembering arguments with only one package using arguments" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $null = Enable-ChocolateyFeature useRememberedArgumentsForUpgrades + $null = Invoke-Choco install curl --package-parameters="'/CurlOnlyParam'" --version="7.77.0" --ia="'/CurlIAParam'" --forcex86 -y + $null = Invoke-Choco install wget --version=1.21.1 -y + + $Output = Invoke-Chocoupgrade all -y --debug + } + + It 'Exits with Success (0)' { + $Output.ExitCode | Should -Be 0 + } + + It 'Outputs running curl script with correct arguments' { + $line = $Output.Lines | ? { $_ -match "packageScript.*curl\\tools" } + + $line | Should -Not -BeNullOrEmpty + $line | Should -Contain "/CurlIAParam" + $line | Should -Contain "/CurlOnlyParam" + $line | Should -Contain "-forceX86" + } + + It 'Outputs running wget script with correct arguments' { + $line = $Output.Lines | ? { $_ -match "packageScript.*curl\\tools" } + + $line | Should -Not -BeNullOrEmpty + $line | Should -Contain "installArguments: ''" + $line | Should -Contain "packageParameters: ''" + $line | Should -Not -Contain "-forceX86" + } + } + + Context "Upgrading packages while remembering arguments with multiple packages using arguments" { + BeforeAll { + Restore-ChocolateyInstallSnapshot + + $null = Enable-ChocolateyFeature useRememberedArgumentsForUpgrades + $null = Invoke-Choco install curl --package-parameters="'/CurlOnlyParam'" --version="7.77.0" --ia="'/CurlIAParam'" --forcex86 -y + $null = Invoke-Choco install wget --version=1.21.1 -y --forcex86 + $null = Invoke-Choco install firefox --version=99.0.1 --package-parameters="'/l=eu'" -y --ia="'/RemoveDistributionDir=true'" + + $Output = Invoke-Chocoupgrade all -y --debug + } + + It 'Exits with Success (0)' { + $Output.ExitCode | Should -Be 0 + } + + It 'Outputs running curl script with correct arguments' { + $line = $Output.Lines | ? { $_ -match "packageScript.*curl\\tools" } + + $line | Should -Not -BeNullOrEmpty + $line | Should -Contain "installArguments: '/CurlIAParam'" + $line | Should -Contain "packageParameters: '/CurlOnlyParam'" + $line | Should -Contain "-forceX86" + } + + It 'Outputs running wget script with correct arguments' { + $line = $Output.Lines | ? { $_ -match "packageScript.*wget\\tools" } + + $line | Should -Not -BeNullOrEmpty + $line | Should -Contain "installArguments: ''" + $line | Should -Contain "packageParameters: ''" + $line | Should -Contain "-forceX86" + } + + It 'Outputs firefox using eu as language locale' { + $Output.Lines | Should -Contain "Using locale 'eu'..." + } + + It 'Outputs running firefox script with correct arguments' { + $line = $Output.Lines | ? { $_ -match "packageScript.*firefox\\tools" } + + $line | Should -Not -BeNullOrEmpty + $line | Should -Contain "installArguments: '/RemoveDistributionDir=true'" + $line | Should -Contain "packageParameters: '/l=eu'" + $line | Should -Not -Contain "-forceX86" + } + } }