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 20, 2022
1 parent 3f17450 commit 75947c3
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions tests/chocolatey-tests/choco-upgrade.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Import-Module helpers/common-helpers

Describe "choco install" -Tag Chocolatey, InstallCommand {
BeforeAll {
Initialize-ChocolateyTestInstall

New-ChocolateyInstallSnapshot
}

AfterAll {
Remove-ChocolateyTestInstall
}

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 75947c3

Please sign in to comment.