(#1039) Improved flow for cases when chocolatey is not installed#1092
Merged
corbob merged 1 commit intochocolatey:masterfrom Jan 26, 2026
Merged
Conversation
Contributor
Author
TestTest result - Detailed Pester Test Results - Chocolatey Availability TestsTest Summary
Test Environment
Test ConfigurationMock Get-Command returns: null
ParameterFilter: Name -eq 'choco.exe'
ErrorAction: SilentlyContinueDetailed Test Results1️⃣ Test: Throws an error when Chocolatey is not found
{ Test-ChocolateyAvailability } | Should -Throw2️⃣ Test: Throws the correct error message
$expectedMessage = 'Chocolatey not installed. Cannot install standard packages.'
{ Test-ChocolateyAvailability } | Should -Throw $expectedMessage3️⃣ Test: Should call Get-Command with correct parameters
Should -Invoke Get-Command -Times 1 -ParameterFilter { $Name -eq 'choco.exe' -and $ErrorAction -eq 'SilentlyContinue' }Function Being Testedfunction Test-ChocolateyAvailability {
if ($null -eq (Get-Command -Name 'choco.exe' -ErrorAction SilentlyContinue)) {
Write-Error "Chocolatey not installed. Cannot install standard packages." -ErrorAction Stop
}
return $true
} |
Contributor
Author
|
@pauby I took liberty to just prep this one. I had more than 2 commits, cos I forgot to update issue's ID number in commit message 😓 |
…ipt for cases when chocolatey is not installed
b4c2ea5 to
9d25a01
Compare
Member
@LeaDevelop Thank you for this contribution. I took the liberty of rebasing it all off of the current master branch and dropping from it the commits with the wrong message. As well as the commit for the chocolatey.server page which no longer has these changes to it. If you're interested, I'm more than happy to expand on what I did to change the commit messages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description Of Changes
The change has following affects:
Motivation and Context
With this correction script will stop and not attempt to install the chocolatey server.
Automated approach will recognize error and for manual options user is able to spot error and logs as PowerShell's window remains open.
Testing
Change Types Made
Change Checklist
Related Issue
Fixes #1039