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 24, 2024
1 parent 644ca3e commit 17ef8a7
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 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,27 @@
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 "--user=[REDACTED ARGUMENT]" -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 +208,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 17ef8a7

Please sign in to comment.