Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created March 17, 2017 22:07
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 bielawb/f3cac1d2e0f2aba4753a974c5d2688ad to your computer and use it in GitHub Desktop.
Save bielawb/f3cac1d2e0f2aba4753a974c5d2688ad to your computer and use it in GitHub Desktop.
Testujemy - etap drugi - prosty mock i kilka it-ów.
Describe 'Testujemy, co się stanie gdy polecenia wybuchną nam w rękach' {
Mock -CommandName Invoke-WebRequest -MockWith { throw 'Bum!' }
try {
Get-GitHubPullRequest -Owner Test -Repository TestRepo
} catch {
$exception = $_.Exception
}
It 'Jak Invoke-WebRequest wybuchnie, dostaniemy błąd z właścicielem' {
$exception.Message | Should Match 'Owned by Test'
}
It 'Jak Invoke-WebRequest wybuchnie, dostaniemy błąd z repozytorium' {
$exception.Message | Should BeLike '* from TestRepo *'
}
It 'Jak Invoke-WebRequest wybuchnie, nasz błąd też będzie wybuchowy' {
$exception.Message | Should BeLike '* Bum!'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment