Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Created October 15, 2021 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/1791ffd845ada76afe12dc75250db4ed to your computer and use it in GitHub Desktop.
Save techthoughts2/1791ffd845ada76afe12dc75250db4ed to your computer and use it in GitHub Desktop.
It 'should run the expected commands if an error is encountered' {
Mock -CommandName Invoke-RestMethod {
throw 'Fake Error'
} #endMock
Mock -CommandName Write-Warning { }
Mock -CommandName Write-Error { }
$sendTelegramContactSplat = @{
BotToken = $token
ChatID = $chat
PhoneNumber = $phone
FirstName = $firstName
LastName = $lastName
DisableNotification = $true
}
Send-TelegramContact @sendTelegramContactSplat
Assert-MockCalled -CommandName Write-Warning -Times 1 -Scope It
Assert-MockCalled -CommandName Write-Error -Times 1 -Scope It
} #it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment