Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#2712) Normalize ExitCode pester tests #3373

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/pester-tests/chocolatey.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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 @@ -345,7 +345,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 @@ -369,7 +369,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
26 changes: 13 additions & 13 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 @@ -42,7 +42,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 @@ -57,7 +57,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 @@ -71,7 +71,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 @@ -104,7 +104,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 @@ -148,7 +148,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 @@ -195,7 +195,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 @@ -243,7 +243,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 @@ -275,7 +275,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 @@ -299,7 +299,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 @@ -317,7 +317,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 @@ -337,7 +337,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 @@ -358,7 +358,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 @@ -62,7 +62,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 @@ -104,7 +104,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 @@ -122,7 +122,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 @@ -140,7 +140,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 @@ -157,7 +157,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 @@ -184,7 +184,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 @@ -211,7 +211,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 @@ -241,7 +241,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 @@ -268,7 +268,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
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 @@ -37,7 +37,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 @@ -124,7 +124,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 @@ -148,7 +148,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 @@ -172,7 +172,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 @@ -192,7 +192,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 @@ -209,7 +209,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 @@ -43,7 +43,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 @@ -68,7 +68,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