Skip to content

Commit

Permalink
Merge pull request #3141 from vexx32/foss-only-tests-upgrade
Browse files Browse the repository at this point in the history
(tests) Mark some upgrade tests for locked files FossOnly
  • Loading branch information
gep13 authored Apr 28, 2023
2 parents 009a926 + 3b9bb57 commit 44c957c
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions tests/chocolatey-tests/commands/choco-upgrade.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ To upgrade a local, or remote file, you may use:
}
}

Context "Upgrading a package when installer is locked" {
# This does not work as expected when runnning in test kitchen and with Chocolatey Licensed Extension installed.
# It is believed to be a problem with test kitchen, or the VM that we are using that is causing the issue.
# The result is that versioned backup files of each file in the package is created, instead of the package being
# removed. Consider the test partially broken.
Context "Upgrading a package when installer is locked" -Tag FossOnly {
BeforeAll {
Restore-ChocolateyInstallSnapshot

Expand Down Expand Up @@ -402,11 +406,19 @@ To upgrade a local, or remote file, you may use:
$null = Invoke-Choco uninstall $PackageUnderTest --confirm
}

It "Exits with Failure (1)" {
# This does not work as expected when runnning in test kitchen and with Chocolatey Licensed Extension installed.
# It is believed to be a problem with test kitchen, or the VM that we are using that is causing the issue.
# The result is that versioned backup files of each file in the package is created, instead of the package being
# removed. Consider the test partially broken.
It "Exits with Failure (1)" -Tag FossOnly {
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Keeps file '<_>' in the lib directory" -ForEach @('hasinnoinstaller.nuspec', 'hasinnoinstaller.nupkg', 'tools\chocolateyinstall.ps1', 'tools\chocolateyuninstall.ps1', 'tools\helloworld-1.0.0.exe', 'tools\helloworld-1.0.0.exe.ignore') {
# This does not work as expected when runnning in test kitchen and with Chocolatey Licensed Extension installed.
# It is believed to be a problem with test kitchen, or the VM that we are using that is causing the issue.
# The result is that versioned backup files of each file in the package is created, instead of the package being
# removed. Consider the test partially broken.
It "Keeps file '<_>' in the lib directory" -ForEach @('hasinnoinstaller.nuspec', 'hasinnoinstaller.nupkg', 'tools\chocolateyinstall.ps1', 'tools\chocolateyuninstall.ps1', 'tools\helloworld-1.0.0.exe', 'tools\helloworld-1.0.0.exe.ignore') -Tag FossOnly {
"$env:ChocolateyInstall\lib\$PackageUnderTest\$_" | Should -Exist
}

Expand All @@ -415,16 +427,25 @@ To upgrade a local, or remote file, you may use:
}

# Only two files are backed up as we was not able to download and extract the new package
It "Creates backup of file '<_>' in lib-bad" -ForEach @('.chocolateyPending', 'tools\a-locked-file.txt') {
# This does not work as expected when runnning in test kitchen and with Chocolatey Licensed Extension installed.
# It is believed to be a problem with test kitchen, or the VM that we are using that is causing the issue.
# The result is that versioned backup files of each file in the package is created, instead of the package being
# removed. Consider the test partially broken.
It "Creates backup of file '<_>' in lib-bad" -ForEach @('.chocolateyPending', 'tools\a-locked-file.txt') -Tag FossOnly {
"$env:ChocolateyInstall\lib-bad\$PackageUnderTest\$PackageVersion\$_" | Should -Exist
}

It "Did not create backup of file '<_>' in lib-bad" -ForEach @('hasinnoinstaller.nuspec', 'hasinnoinstaller.nupkg', 'tools\chocolateyinstall.ps1', 'tools\chocolateyuninstall.ps1', 'tools\helloworld-1.0.0.exe', 'helloworld-1.0.0.exe.ignore') {
"$env:ChocolateyInstall\lib-bad\$PackageUnderTest\$PackageVersion\$_" | Should -Not -Exist
}

It "Outputs a message showing that installation failed." {
$Output.Lines | Should -Contain "Chocolatey upgraded 0/1 packages. 1 packages failed."
# This does not work as expected when runnning in test kitchen and with Chocolatey Licensed Extension installed.
# It is believed to be a problem with test kitchen, or the VM that we are using that is causing the issue.
# The result is that versioned backup files of each file in the package is created, instead of the package being
# removed. Consider the test partially broken.
It "Outputs a message showing that installation failed." -Tag FossOnly {

$Output.Lines | Should -Contain "Chocolatey upgraded 0/1 packages. 1 packages failed." -Because $Output.String
}
}

Expand Down

0 comments on commit 44c957c

Please sign in to comment.