Skip to content

Commit

Permalink
(chocolatey#1443) Add E2E tests for remember upgrade args
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Sep 21, 2022
1 parent b467bb3 commit 2edef72
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/chocolatey-tests/choco-upgrade.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}

0 comments on commit 2edef72

Please sign in to comment.