Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Created April 9, 2021 09:17
Show Gist options
  • Save nohwnd/a02cdc09cedac54365e34861d59146a8 to your computer and use it in GitHub Desktop.
Save nohwnd/a02cdc09cedac54365e34861d59146a8 to your computer and use it in GitHub Desktop.
Get parameter value from Mock without using $script: scope
# Keeping a value from a mock call, or some other place
# while avoiding $script: to keep script scope clean
Describe "a" {
It 'Test' {
function Get-GitHubRelease ($Release) { }
# use a reference object instead of directly assiging to a
# variable to collect the values from a mock call
$container = @{}
Mock Get-GitHubRelease {
$container.Release = $Release
}
Get-GitHubRelease -Release 89723498
$container.Release | Should -Be 89723498
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment