Hello,
I want to unit test my install/uninstall scripts using pester. Therefore it would be nice if there would be a easy solution to load all the helper functions into the test file. I know I could do it one by one like this:
. C:\ProgramData\chocolatey\helpers\functions\Get-ChocolateyUnzip.ps1
. .\chocolateyinstall.ps1
Describe "Test1"{
However this isn't really comfortable. Does anyone have an idea how I could do this more compact?
Or does a solution for this already exist?
Not sure if chocolatey has a builtin helper load function, but you can always do something like this:
Get-ChildItem -Path 'C:\ProgramData\chocolatey\helpers\functions\' -Filter *.ps1 | ForEach-Object {
. $_.Fullname
}
This might work.
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
Import-Module $env:ChocolateyInstall\helpers\chocolateyInstaller.psm1
@daveMueller use the second line that @TheCakeIsNaOH posted (the chocolateyInstaller.psm1 one), this will import all of the chocolatey functions and any installed chocolatey extension to the current powershell session.
Hey thanks for all the answers. I successfully tested it and I can use it.
Most helpful comment
@daveMueller use the second line that @TheCakeIsNaOH posted (the
chocolateyInstaller.psm1one), this will import all of the chocolatey functions and any installed chocolatey extension to the current powershell session.