Last active
January 5, 2023 04:55
-
-
Save techthoughts2/9b164ef48631b0d0ee5a404b11736ee8 to your computer and use it in GitHub Desktop.
Pester test a command that should be called with certain parameters
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
# test a command that should be called with certain parameters | |
#------------------------------------------------------------------------------ | |
It 'should call the API with the expected parameters' { | |
Mock -CommandName Invoke-RestMethod { | |
} -Verifiable -ParameterFilter { $Uri -like 'https://api.telegram.org/bot*getStickerSet*' } | |
# "https://api.telegram.org/bot$BotToken/getStickerSet" | |
$getTelegramStickerPackInfoSplat = @{ | |
BotToken = $token | |
StickerSetName = 'STPicard' | |
} | |
Get-TelegramStickerPackInfo @getTelegramStickerPackInfoSplat | |
Assert-VerifiableMock | |
} #it | |
#------------------------------------------------------------------------------ | |
It 'should call the API with the expected parameters' { | |
Mock -CommandName Invoke-RestMethod { | |
$Uri | Should -BeExactly 'https://api.github.com/repos/Azure/azure-powershell/releases' | |
$ContentType | Should -BeExactly 'application/json' | |
$ErrorAction | Should -BeExactly 'Stop' | |
} -Verifiable | |
Get-GitHubReleaseInfo -RepositoryName 'Azure/azure-powershell' | Should -InvokeVerifiable | |
} #it | |
#------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment