Skip to content

Commit

Permalink
(#1185) Be explicit with expected exit codes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
corbob committed Sep 26, 2022
1 parent 8cb1f23 commit 794bf67
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/chocolatey-tests/features/Hooks.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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 = 0 }
@{ Flag = '--skip-powershell' ; RunsHooks = $false ; Command = 'uninstall' ; ExitCode = 0 }
@{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'uninstall' ; ExitCode = 0 }

@{ 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 = 0 }
@{ Flag = '--skip-hooks' ; RunsHooks = $false ; Command = 'upgrade' ; ExitCode = -1 }

)
}
Expand Down Expand Up @@ -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 (<ExitCode>)" {
$Output.ExitCode | Should -Be $ExitCode -Because $Output.String
}

It "Should execute hooks (<RunsHooks>)" {
Expand Down

0 comments on commit 794bf67

Please sign in to comment.