|
| 1 | +Import-Module helpers/common-helpers |
| 2 | + |
| 3 | +Describe "choco upgrade" -Tag Chocolatey, UpgradeCommand { |
| 4 | + BeforeAll { |
| 5 | + Initialize-ChocolateyTestInstall |
| 6 | + |
| 7 | + New-ChocolateyInstallSnapshot |
| 8 | + } |
| 9 | + |
| 10 | + AfterAll { |
| 11 | + Remove-ChocolateyTestInstall |
| 12 | + } |
| 13 | + |
| 14 | + Context "Can upgrade packages with dependencies containing side by side installations and outdated dependency" { |
| 15 | + BeforeAll { |
| 16 | + Restore-ChocolateyInstallSnapshot |
| 17 | + |
| 18 | + $null = Invoke-Choco install chocolatey-core.extension --version 1.3.0 --confirm |
| 19 | + $null = Invoke-Choco install 7zip --version 16.04 --confirm |
| 20 | + $null = Invoke-Choco install chocolatey-core.extension --version 1.3.5.1 --sxs --confirm |
| 21 | + |
| 22 | + $Output = Invoke-Choco upgrade 7zip --version 21.7 --confirm |
| 23 | + } |
| 24 | + |
| 25 | + AfterAll { |
| 26 | + $null = Invoke-Choco uninstall 7zip 7zip.install --confirm |
| 27 | + } |
| 28 | + |
| 29 | + It "Exits with Success (0)" { |
| 30 | + $Output.ExitCode | Should -Be 0 -Because $Output.String |
| 31 | + } |
| 32 | + |
| 33 | + It "Upgrades version <OldVersion> of the package <Name>" -ForEach @( |
| 34 | + @{ Name = "7zip"; OldVersion = "16.04" } |
| 35 | + @{ Name = "7zip.install"; OldVersion = "16.04" } |
| 36 | + @{ Name = "chocolatey-core.extension"; OldVersion = "1.3.0" } |
| 37 | + ) { |
| 38 | + "$env:ChocolateyInstall\lib\$Name\$Name.nuspec" | Should -Exist |
| 39 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$Name\$Name.nuspec" |
| 40 | + $XML.package.metadata.version | Should -Not -Be $OldVersion |
| 41 | + } |
| 42 | + |
| 43 | + It "Have not upgraded side by side installation of <Name> v<Version>" -ForEach @( |
| 44 | + @{ Name = "chocolatey-core.extension"; Version = "1.3.5.1" } |
| 45 | + ) { |
| 46 | + "$env:ChocolateyInstall\lib\$Name.$Version\$Name.$Version.nupkg" | Should -Exist |
| 47 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$Name.$Version\$Name.$Version.nuspec" |
| 48 | + $XML.package.metadata.id | Should -Be $Name |
| 49 | + $XML.package.metadata.version | Should -Be $Version |
| 50 | + } |
| 51 | + |
| 52 | + It "Outputs a message showing that upgrading was successful" { |
| 53 | + $Output.String | SHould -Match "Chocolatey upgraded 3/3 packages\." |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + Context "Can upgrade packages with dependencies containing side by side installations and up to date dependency" { |
| 58 | + BeforeAll { |
| 59 | + Restore-ChocolateyInstallSnapshot |
| 60 | + |
| 61 | + $null = Invoke-Choco install chocolatey-core.extension --version 1.3.3 --confirm |
| 62 | + $null = Invoke-Choco install 7zip --version 16.04 --confirm |
| 63 | + $null = Invoke-Choco install chocolatey-core.extension --version 1.3.5.1 --sxs --confirm |
| 64 | + |
| 65 | + $Output = Invoke-Choco upgrade 7zip --version 21.7 --confirm |
| 66 | + } |
| 67 | + |
| 68 | + AfterAll { |
| 69 | + $null = Invoke-Choco uninstall 7zip 7zip.install --confirm |
| 70 | + } |
| 71 | + |
| 72 | + It "Exits with Success (0)" { |
| 73 | + $Output.ExitCode | Should -Be 0 -Because $Output.String |
| 74 | + } |
| 75 | + |
| 76 | + It "Upgrades version <OldVersion> of the package <Name>" -ForEach @( |
| 77 | + @{ Name = "7zip"; OldVersion = "16.04" } |
| 78 | + @{ Name = "7zip.install"; OldVersion = "16.04" } |
| 79 | + ) { |
| 80 | + "$env:ChocolateyInstall\lib\$Name\$Name.nuspec" | Should -Exist |
| 81 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$Name\$Name.nuspec" |
| 82 | + $XML.package.metadata.version | Should -Not -Be $OldVersion |
| 83 | + } |
| 84 | + |
| 85 | + It "Have not upgraded dependency <Name>" { |
| 86 | + "$env:ChocolateyInstall\lib\chocolatey-core.extension\chocolatey-core.extension.nupkg" | Should -Exist |
| 87 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\chocolatey-core.extension\chocolatey-core.extension.nuspec" |
| 88 | + $XML.package.metadata.id | Should -Be 'chocolatey-core.extension' |
| 89 | + $XML.package.metadata.version | Should -Be '1.3.3' |
| 90 | + } |
| 91 | + |
| 92 | + It "Have not upgraded side by side installation of <Name> v<Version>" -ForEach @( |
| 93 | + @{ Name = "chocolatey-core.extension"; Version = "1.3.5.1" } |
| 94 | + ) { |
| 95 | + "$env:ChocolateyInstall\lib\$Name.$Version\$Name.$Version.nupkg" | Should -Exist |
| 96 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$Name.$Version\$Name.$Version.nuspec" |
| 97 | + $XML.package.metadata.id | Should -Be $Name |
| 98 | + $XML.package.metadata.version | Should -Be $Version |
| 99 | + } |
| 100 | + |
| 101 | + It "Outputs a message showing that upgrading was successful" { |
| 102 | + $Output.String | SHould -Match "Chocolatey upgraded 2/2 packages\." |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + |
| 107 | + Context "Can upgrade packages with dependencies containing outdated side by side installations and up to date dependency" { |
| 108 | + BeforeAll { |
| 109 | + Restore-ChocolateyInstallSnapshot |
| 110 | + |
| 111 | + $null = Invoke-Choco install chocolatey-core.extension --version 1.3.3 --confirm |
| 112 | + $null = Invoke-Choco install 7zip --version 16.04 --confirm |
| 113 | + $null = Invoke-Choco install chocolatey-core.extension --version 1.3.0 --sxs --confirm |
| 114 | + |
| 115 | + $Output = Invoke-Choco upgrade 7zip --version 21.7 --confirm |
| 116 | + } |
| 117 | + |
| 118 | + AfterAll { |
| 119 | + $null = Invoke-Choco uninstall 7zip 7zip.install --confirm |
| 120 | + } |
| 121 | + |
| 122 | + It "Exits with Success (0)" { |
| 123 | + $Output.ExitCode | Should -Be 0 -Because $Output.String |
| 124 | + } |
| 125 | + |
| 126 | + It "Upgrades version <OldVersion> of the package <Name>" -ForEach @( |
| 127 | + @{ Name = "7zip"; OldVersion = "16.04" } |
| 128 | + @{ Name = "7zip.install"; OldVersion = "16.04" } |
| 129 | + ) { |
| 130 | + "$env:ChocolateyInstall\lib\$Name\$Name.nuspec" | Should -Exist |
| 131 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$Name\$Name.nuspec" |
| 132 | + $XML.package.metadata.version | Should -Not -Be $OldVersion |
| 133 | + } |
| 134 | + |
| 135 | + It "Have not upgraded dependency chocolatey-core.extension" { |
| 136 | + "$env:ChocolateyInstall\lib\chocolatey-core.extension\chocolatey-core.extension.nupkg" | Should -Exist |
| 137 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\chocolatey-core.extension\chocolatey-core.extension.nuspec" |
| 138 | + $XML.package.metadata.id | Should -Be 'chocolatey-core.extension' |
| 139 | + $XML.package.metadata.version | Should -Be '1.3.3' |
| 140 | + } |
| 141 | + |
| 142 | + It "Have not upgraded side by side installation of <Name> v<Version>" -ForEach @( |
| 143 | + @{ Name = "chocolatey-core.extension"; Version = "1.3.0" } |
| 144 | + ) { |
| 145 | + "$env:ChocolateyInstall\lib\$Name.$Version\$Name.$Version.nupkg" | Should -Exist |
| 146 | + [xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$Name.$Version\$Name.$Version.nuspec" |
| 147 | + $XML.package.metadata.id | Should -Be $Name |
| 148 | + $XML.package.metadata.version | Should -Be $Version |
| 149 | + } |
| 150 | + |
| 151 | + It "Outputs a message showing that upgrading was successful" { |
| 152 | + $Output.String | SHould -Match "Chocolatey upgraded 2/2 packages\." |
| 153 | + } |
| 154 | + } |
| 155 | +} |
0 commit comments