diff --git a/tests/chocolatey-tests/choco-install.Tests.ps1 b/tests/chocolatey-tests/choco-install.Tests.ps1 index 2a810317b5..9e2a06940d 100644 --- a/tests/chocolatey-tests/choco-install.Tests.ps1 +++ b/tests/chocolatey-tests/choco-install.Tests.ps1 @@ -1393,6 +1393,37 @@ Describe "choco install" -Tag Chocolatey, InstallCommand { } } + Context "Install '' package with () specified" -ForEach @( + @{ Command = '--pin' ; Package = 'installpackage' ; Contains = $true } + @{ Command = '' ; Package = 'installpackage' ; Contains = $false } + @{ Command = '' ; Package = 'packages.config' ; Contains = $true } + ) -Tag Mine { + BeforeAll { + Restore-ChocolateyInstallSnapshot -SetWorkDir + + if ($Package -eq 'packages.config') { + @" + + + + +"@ | Set-Content $PWD/packages.config + } + + $null = Invoke-Choco install $Package $Command --confirm + $Output = Invoke-Choco pin list + } + + It "Output should include pinned package" { + if ($Contains) { + $Output.Lines | Should -Contain "installpackage|1.0.0" + } + else { + $Output.Lines | Should -Not -Contain "installpackage|1.0.0" + } + } + } + Context "Installing package that extracts local zip archive while disabling logging" { BeforeAll { Restore-ChocolateyInstallSnapshot diff --git a/tests/chocolatey-tests/choco-upgrade.Tests.ps1 b/tests/chocolatey-tests/choco-upgrade.Tests.ps1 index 25b8d785fc..be6fee6ea0 100644 --- a/tests/chocolatey-tests/choco-upgrade.Tests.ps1 +++ b/tests/chocolatey-tests/choco-upgrade.Tests.ps1 @@ -120,6 +120,35 @@ Describe "choco upgrade" -Tag Chocolatey, UpgradeCommand { } } + Context "Upgrade package with () specified" -ForEach @( + @{ Command = '--pin' ; Contains = $true } + @{ Command = '' ; Contains = $false } + ) -tag mine { + BeforeAll { + Restore-ChocolateyInstallSnapshot -SetWorkDir + + $Package = 'upgradepackage' + $null = Invoke-Choco install $Package --version 1.0.0 --confirm + $hmmm = Invoke-Choco upgrade $Package $Command --confirm + write-host $hmmm.string + write-host $hmmm.ExitCode + $Output = Invoke-Choco pin list + } + + It "Exits with Success (0)" { + $Output.ExitCode | Should -Be 0 + } + + It "Output should include pinned package" { + if ($Contains) { + $Output.Lines | Should -Contain "$Package|1.1.0" + } + else { + $Output.Lines | Should -Not -Contain "$Package|1.1.0" + } + } + } + Context "Upgrading packages while remembering arguments with only one package using arguments" -Tag Internal { BeforeAll { Restore-ChocolateyInstallSnapshot