forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolatey#2787) Add tests for side-by-side deprecation
- Loading branch information
1 parent
c3de6e7
commit 9e4c4bc
Showing
7 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > | ||
<section name="SteveCadwallader.CodeMaid.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | ||
</sectionGroup> | ||
</configSections> | ||
<userSettings> | ||
<SteveCadwallader.CodeMaid.Properties.Settings> | ||
<setting name="Cleaning_UpdateFileHeader_HeaderUpdateMode" serializeAs="String"> | ||
<value>1</value> | ||
</setting> | ||
<setting name="Cleaning_UpdateFileHeaderCSharp" serializeAs="String"> | ||
<value>// Copyright © 2017 - 2022 Chocolatey Software, Inc | ||
// Copyright © 2011 - 2017 RealDimensions Software, LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License.</value> | ||
</setting> | ||
<setting name="Cleaning_AutoCleanupOnFileSave" serializeAs="String"> | ||
<value>True</value> | ||
</setting> | ||
<setting name="Cleaning_InsertEndOfFileTrailingNewLine" serializeAs="String"> | ||
<value>True</value> | ||
</setting> | ||
</SteveCadwallader.CodeMaid.Properties.Settings> | ||
</userSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Import-Module helpers/common-helpers | ||
|
||
Describe "choco uninstall" -Tag Chocolatey, UninstallCommand { | ||
BeforeAll { | ||
Initialize-ChocolateyTestInstall | ||
|
||
New-ChocolateyInstallSnapshot | ||
} | ||
|
||
AfterAll { | ||
Remove-ChocolateyTestInstall | ||
} | ||
|
||
Context "Uninstalling a side-by-side Package" { | ||
BeforeAll { | ||
Restore-ChocolateyInstallSnapshot | ||
|
||
$PackageUnderTest = "installpackage" | ||
|
||
$null = Invoke-Choco upgrade $PackageUnderTest --confirm --allowmultipleversions | ||
|
||
$Output = Invoke-Choco uninstall $PackageUnderTest --confirm | ||
} | ||
|
||
It "Exits with Success (0)" { | ||
$Output.ExitCode | Should -Be 0 | ||
} | ||
|
||
It "Removed a package to the lib directory" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest).1.0.0" | Should -Not -Exist | ||
"$env:ChocolateyInstall\lib-bad\$($PackageUnderTest).1.0.0" | Should -Not -Exist | ||
} | ||
|
||
It "Outputs a warning message that installed side by side package is deprecated" { | ||
$Output.Lines | Should -Contain "$PackageUnderTest has been installed as a side by side installation." -Because $Output.String | ||
$Output.Lines | Should -Contain "Side by side installations are deprecated and is pending removal in v2.0.0." -Because $Output.String | ||
} | ||
|
||
It "Outputs a message indicating that it uninstalled the package successfully" { | ||
$Output.Lines | Should -Contain "Chocolatey uninstalled 1/1 packages." -Because $Output.String | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
Import-Module helpers/common-helpers | ||
|
||
Describe "choco upgrade" -Tag Chocolatey, UpgradeCommand { | ||
BeforeAll { | ||
Initialize-ChocolateyTestInstall | ||
|
||
New-ChocolateyInstallSnapshot | ||
} | ||
|
||
AfterAll { | ||
Remove-ChocolateyTestInstall | ||
} | ||
|
||
Context "Upgrading a side-by-side Package (non-existing)" { | ||
BeforeAll { | ||
Restore-ChocolateyInstallSnapshot | ||
|
||
$PackageUnderTest = "installpackage" | ||
|
||
$Output = Invoke-Choco upgrade $PackageUnderTest --confirm --allowmultipleversions | ||
} | ||
|
||
It "Exits with Success (0)" { | ||
$Output.ExitCode | Should -Be 0 | ||
} | ||
|
||
It "Installed a package to the lib directory" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest).1.0.0" | Should -Exist | ||
} | ||
|
||
It "Installs the expected version of the package" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest).1.0.0\$($PackageUnderTest).1.0.0.nuspec" | Should -Exist | ||
[xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$($PackageUnderTest).1.0.0\$($PackageUnderTest).1.0.0.nuspec" | ||
$XML.package.metadata.version | Should -Be "1.0.0" | ||
} | ||
|
||
It "Outputs a warning message about side by side installs are deprecated" { | ||
$Output.Lines | Should -Contain "Upgrading the same package with multiple versions is deprecated and will be removed in v2.0.0." -Because $Output.String | ||
} | ||
|
||
It "Outputs a message indicating that it upgraded the package successfully" { | ||
$Output.Lines | Should -Contain "Chocolatey upgraded 1/1 packages." -Because $Output.String | ||
} | ||
} | ||
|
||
Context "Switching a normal Package to a side-by-side Package" { | ||
BeforeAll { | ||
Restore-ChocolateyInstallSnapshot | ||
|
||
$PackageUnderTest = "installpackage" | ||
|
||
$null = Invoke-Choco install $PackageUnderTest --confirm | ||
|
||
$Output = Invoke-Choco upgrade $PackageUnderTest --confirm --force --allowmultipleversions | ||
} | ||
|
||
It "Exits with Success (0)" { | ||
$Output.ExitCode | Should -Be 0 | ||
} | ||
|
||
It "Installed the package to the lib directory" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest).1.0.0" | Should -Exist | ||
} | ||
|
||
It "Removed the previous version of the package from the lib directory" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest)" | Should -Not -Exist | ||
} | ||
|
||
It "Installs the expected version of the package" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest).1.0.0\$($PackageUnderTest).1.0.0.nuspec" | Should -Exist | ||
[xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$($PackageUnderTest).1.0.0\$($PackageUnderTest).1.0.0.nuspec" | ||
$XML.package.metadata.version | Should -Be "1.0.0" | ||
} | ||
|
||
It "Outputs a warning message about side by side installs are deprecated" { | ||
$Output.Lines | Should -Contain "Upgrading the same package with multiple versions is deprecated and will be removed in v2.0.0." -Because $Output.String | ||
} | ||
|
||
It "Outputs a message indicating that it upgraded the package successfully" { | ||
$Output.Lines | Should -Contain "Chocolatey upgraded 1/1 packages." -Because $Output.String | ||
} | ||
} | ||
|
||
Context "Switching a side-by-side Package to a normal Package" { | ||
BeforeAll { | ||
Restore-ChocolateyInstallSnapshot | ||
|
||
$PackageUnderTest = "installpackage" | ||
|
||
$null = Invoke-Choco install $PackageUnderTest --confirm --allowmultipleversion | ||
|
||
$Output = Invoke-Choco upgrade $PackageUnderTest --confirm --force | ||
} | ||
|
||
It "Exits with Success (0)" { | ||
$Output.ExitCode | Should -Be 0 | ||
} | ||
|
||
It "Installed the package to the lib directory" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest)" | Should -Exist | ||
} | ||
|
||
It "Installs the expected version of the package" { | ||
"$env:ChocolateyInstall\lib\$($PackageUnderTest)\$($PackageUnderTest).nuspec" | Should -Exist | ||
[xml]$XML = Get-Content "$env:ChocolateyInstall\lib\$($PackageUnderTest)\$($PackageUnderTest).nuspec" | ||
$XML.package.metadata.version | Should -Be "1.0.0" | ||
} | ||
|
||
It "Does not output a warning message about side by side installs are deprecated" { | ||
$Output.Lines | Should -Not -Contain "Upgrading the same package with multiple versions is deprecated and will be removed in v2.0.0." -Because $Output.String | ||
} | ||
|
||
It "Does not output a warning message that installed side by side package is deprecated" { | ||
$Output.Lines | Should -Not -Contain "installpackage has been installed as a side by side installation." -Because $Output.String | ||
$Output.Lines | Should -Not -Contain "Side by side installations are deprecated and is pending removal in v2.0.0." -Because $Output.String | ||
} | ||
|
||
It "Outputs a message indicating that it upgraded the package successfully" { | ||
$Output.Lines | Should -Contain "Chocolatey upgraded 1/1 packages." -Because $Output.String | ||
} | ||
} | ||
} |