Skip to content

Commit

Permalink
(chocolatey#2050) Add Pester test for --ignore-pinned option
Browse files Browse the repository at this point in the history
With the next release of Chocolatey CLI, it is possible to run choco
upgrade --ignore-pinned, rather than first having to run a choco pin
remove command.

This commit adds a Pester test to cover the usage of the
--ignore-pinned option on the upgrade command.  This tests relies on
correct execution of the --pin option on the install command, but this
is tested elsewhere.
  • Loading branch information
gep13 committed May 30, 2024
1 parent a46f1df commit a3aeaca
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/pester-tests/commands/choco-upgrade.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,36 @@
Remove-ChocolateyTestInstall
}

Context "Upgrade pinned package using (<Command>) option" -ForEach @(
@{ Command = '--ignore-pinned' ; Contains = $true }
@{ Command = '' ; Contains = $false }
) {
BeforeAll {
Restore-ChocolateyInstallSnapshot

$Package = 'upgradepackage'

# This test relies on the correct usage of the --pin option on the install
# command, but this is tested elsewhere
$null = Invoke-Choco install $Package --pin --version 1.0.0 --confirm
$null = Invoke-Choco upgrade $Package $Command --confirm
$Output = Invoke-Choco pin list
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Output should include upgraded package, with new pin in place" {
if ($Contains) {
$Output.String | Should -Match "$Package|1.1.0"
}
else {
$Output.String | Should -Match "$Package|1.0.0"
}
}
}

Context "Upgrade package with (<Command>) specified" -ForEach @(
@{ Command = '--pin' ; Contains = $true }
@{ Command = '' ; Contains = $false }
Expand Down

0 comments on commit a3aeaca

Please sign in to comment.