Skip to content

Commit

Permalink
Merge pull request #3372 from corbob/fix-support-tests
Browse files Browse the repository at this point in the history
(#2712) Normalize ExitCode pester test on Support Branch
  • Loading branch information
gep13 authored Dec 20, 2023
2 parents 809e847 + 89b3eef commit a425c67
Show file tree
Hide file tree
Showing 20 changed files with 179 additions and 176 deletions.
6 changes: 3 additions & 3 deletions tests/pester-tests/chocolatey.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
It "Outputs the version when run with --version" {
$Output = Invoke-Choco --version
$script:CurrentVersion = $Output.String
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
$LastExitCode | Should -Be 0
($Output.String -split '-' | Select-Object -First 1) -as [version] | Should -BeTrue
}
Expand Down Expand Up @@ -333,7 +333,7 @@ exit $error.count
}

It 'should exit Success (0)' {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It 'should <removal> shim <_> on upgrade' -ForEach $RemovedShims {
Expand All @@ -356,7 +356,7 @@ exit $error.count
}

It 'Exits with Success (0)' {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It 'Should remove the invalid configuration file' {
Expand Down
22 changes: 11 additions & 11 deletions tests/pester-tests/commands/choco-apikey.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Only displays chocolatey name with version" {
Expand All @@ -44,7 +44,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Only displays chocolatey name with version" {
Expand All @@ -59,7 +59,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Only displays chocolatey name with version" {
Expand All @@ -75,7 +75,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Only displays chocolatey name with version" {
Expand Down Expand Up @@ -108,7 +108,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand Down Expand Up @@ -155,7 +155,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand Down Expand Up @@ -190,7 +190,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand Down Expand Up @@ -219,7 +219,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -237,7 +237,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Failure (1)" {
$Output.ExitCode | Should -Be 1
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -257,7 +257,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -280,7 +280,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ApiKeyCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand Down
18 changes: 9 additions & 9 deletions tests/pester-tests/commands/choco-config.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand Down Expand Up @@ -173,7 +173,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -191,7 +191,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -209,7 +209,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with failure (1)" {
$Output.ExitCode | Should -Be 1
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Outputs an error indicating that there's no config by that name" {
Expand All @@ -226,7 +226,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -253,7 +253,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -280,7 +280,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand Down Expand Up @@ -310,7 +310,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand All @@ -337,7 +337,7 @@ Describe "choco config" -Tag Chocolatey, ConfigCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays chocolatey name with version" {
Expand Down
2 changes: 1 addition & 1 deletion tests/pester-tests/commands/choco-deprecated.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Describe "Deprecated Chocolatey Helper Commands" -Skip:(-not (Test-ChocolateyVer
}

It 'should exit success (0)' {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It 'should warn that Get-BinRoot is deprecated' {
Expand Down
20 changes: 10 additions & 10 deletions tests/pester-tests/commands/choco-export.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Displays description of command" {
Expand Down Expand Up @@ -133,7 +133,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

# NOTE: There is no output other than the header, and possibly the unofficial statement
Expand Down Expand Up @@ -184,7 +184,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

# NOTE: There is no output other than the header, and possibly the unofficial statement
Expand Down Expand Up @@ -226,7 +226,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

# NOTE: There is no output other than the header, and possibly the unofficial statement
Expand Down Expand Up @@ -277,7 +277,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

# NOTE: There is no output other than the header, and possibly the unofficial statement
Expand Down Expand Up @@ -319,7 +319,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

# NOTE: There is no output other than the header, and possibly the unofficial statement
Expand Down Expand Up @@ -387,7 +387,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

# NOTE: There is no output other than the header, and possibly the unofficial statement
Expand Down Expand Up @@ -415,7 +415,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with Failure (1)" {
$Output.ExitCode | Should -Be 1
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Reports unable to export packages" {
Expand All @@ -439,7 +439,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with Failure (1)" {
$Output.ExitCode | Should -Be 1
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Reports unable to export packages" {
Expand All @@ -459,7 +459,7 @@ Describe "choco export" -Tag Chocolatey, ExportCommand {
}

It "Exits with Failure (1)" {
$Output.ExitCode | Should -Be 1
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Displays help page" {
Expand Down
12 changes: 6 additions & 6 deletions tests/pester-tests/commands/choco-feature.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Lists available features" {
Expand Down Expand Up @@ -121,7 +121,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Outputs a message indicating that it disabled the feature" {
Expand All @@ -145,7 +145,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Outputs a message indicating that it enabled the feature" {
Expand All @@ -169,7 +169,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand {
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Outputs a message indicating that it disabled the feature" {
Expand All @@ -189,7 +189,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand {
}

It "Exits with Failure (1)" {
$Output.ExitCode | Should -Be 1
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Outputs a message indicating it didn't find the feature in question" {
Expand All @@ -206,7 +206,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, FeatureCommand {
}

It "Exits with Failure (1)" {
$Output.ExitCode | Should -Be 1
$Output.ExitCode | Should -Be 1 -Because $Output.String
}

It "Outputs a message indicating it didn't find the feature in question" {
Expand Down
4 changes: 2 additions & 2 deletions tests/pester-tests/commands/choco-help.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Describe "choco help sections with option <_>" -ForEach $HelpOptions -Tag Chocol
}

It "Exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Outputs the Top-Level Help" {
Expand All @@ -70,7 +70,7 @@ Describe "choco help sections with option <_>" -ForEach $HelpOptions -Tag Chocol
}

It "'choco <_> $helpArgument' exits with Success (0)" {
$Output.ExitCode | Should -Be 0
$Output.ExitCode | Should -Be 0 -Because $Output.String
}

It "Outputs help for <_>" {
Expand Down
Loading

0 comments on commit a425c67

Please sign in to comment.