From c78ca1c9523ec0d559053ee36608972187004c4c Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Fri, 23 Sep 2022 11:53:08 -0700 Subject: [PATCH] (#1185) Be explicit with expected exit codes With the upgrade package used in the tests, it currently exits with -1 even though it is successful. Instead of blindly accepting 0 and -1 for all the tests, be explicit about which one we expect so we can catch changes to this exit code. --- .../chocolatey-tests/features/Hooks.Tests.ps1 | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/chocolatey-tests/features/Hooks.Tests.ps1 b/tests/chocolatey-tests/features/Hooks.Tests.ps1 index 2087bdbe5b..4dd2ff2378 100644 --- a/tests/chocolatey-tests/features/Hooks.Tests.ps1 +++ b/tests/chocolatey-tests/features/Hooks.Tests.ps1 @@ -1,19 +1,19 @@ Import-Module helpers/common-helpers -Describe "hooks tests" -Tag Chocolatey, Hooks { +Describe "choco hooks tests" -Tag Chocolatey, HooksFeature { BeforeDiscovery { $Flags = @( - @{ Flag = '' ; RunsHooks = $true ; Command = 'install' } - @{ Flag = '--skip-powershell' ; RunsHooks = $false ; Command = 'install' } - @{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'install' } + @{ Flag = '' ; RunsHooks = $true ; Command = 'install' ; ExitCode = 0 } + @{ Flag = '--skip-powershell' ; RunsHooks = $false ; Command = 'install' ; ExitCode = 0 } + @{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'install' ; ExitCode = 0 } - @{ Flag = '' ; RunsHooks = $true ; Command = 'uninstall' } - @{ Flag = '--skip-powershell' ; RunsHooks = $false ; Command = 'uninstall' } - @{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'uninstall' } + @{ Flag = '' ; RunsHooks = $true ; Command = 'uninstall' ; ExitCode = -1 } + @{ Flag = '--skip-powershell' ; RunsHooks = $false ; Command = 'uninstall' ; ExitCode = -1 } + @{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'uninstall' ; ExitCode = -1 } - @{ Flag = '' ; RunsHooks = $true ; Command = 'upgrade' } - @{ Flag = '--skip-powershell' ; RunsHooks = $false ; Command = 'upgrade' } - @{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'upgrade' } + @{ Flag = '' ; RunsHooks = $true ; Command = 'upgrade' ; ExitCode = -1 } + @{ Flag = '--skip-powershell' ; RunsHooks = $false ; Command = 'upgrade' ; ExitCode = -1 } + @{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'upgrade' ; ExitCode = -1 } ) } @@ -47,8 +47,8 @@ Describe "hooks tests" -Tag Chocolatey, Hooks { } # Uninstall/Upgrade exit -1: https://github.com/chocolatey/choco/issues/2822 - It "Exits with Success (0,-1)" { - $Output.ExitCode | Should -BeIn @(0, -1) -Because $Output.String + It "Exits with expected value ()" { + $Output.ExitCode | Should -Be $ExitCode -Because $Output.String } It "Should execute hooks ()" {