Skip to content

Commit

Permalink
(chocolatey#1310) Add Pester test to validate output
Browse files Browse the repository at this point in the history
Remembered arguments can now be displayed when running the choco info
command, using the --local-only option.

This commit adds a test to verify that this is correctly shown.
  • Loading branch information
gep13 committed May 30, 2024
1 parent 9205c4d commit 579d316
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/pester-tests/commands/choco-info.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@
Remove-ChocolateyTestInstall
}

Context "Should include remembered arguments (including redacted) when using option --local-only" {
BeforeAll {
Remove-NuGetPaths
Initialize-ChocolateyTestInstall -Source $PSScriptRoot\testpackages
Invoke-Choco install installpackage --package-parameters="bob" --user="bill" --password="secure-password" --confirm

$Output = Invoke-Choco info installpackage --local-only
}

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

It "Should contain a summary" {
$Output.Lines | Should -Contain "Remembered Package Arguments:" -Because $Output.String
$Output.Lines | Should -Contain "--package-parameters='bob'" -Because $Output.String
$Output.Lines | Should -Contain "--password=[REDACTED ARGUMENT]" -Because $Output.String
}
}

Context "Listing package information when package can be found" {
BeforeDiscovery {
$infoItems = @(
Expand Down Expand Up @@ -187,11 +207,11 @@
}

It 'Outputs warning about unable to load service index' {
$Output.Lines | Should -Contain "Unable to load the service index for source $InvalidSource."
$Output.Lines | Should -Contain "Unable to load the service index for source $InvalidSource." -Because $Output.String
}

It 'Output information about the package' {
$Output.String | Should -Match "Title: Chocolatey "
$Output.String | Should -Match "Title: Chocolatey " -Because $Output.String
}
}

Expand Down

0 comments on commit 579d316

Please sign in to comment.