diff --git a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 index 1dc59ffa7..b0f0e178f 100644 --- a/tests/pester-tests/commands/choco-upgrade.Tests.ps1 +++ b/tests/pester-tests/commands/choco-upgrade.Tests.ps1 @@ -11,6 +11,36 @@ Remove-ChocolateyTestInstall } + Context "Upgrade pinned package using () 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 () specified" -ForEach @( @{ Command = '--pin' ; Contains = $true } @{ Command = '' ; Contains = $false }