Created
April 9, 2021 09:17
-
-
Save nohwnd/a02cdc09cedac54365e34861d59146a8 to your computer and use it in GitHub Desktop.
Get parameter value from Mock without using $script: scope
This file contains 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
# 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