Assert-MockCalled is not compatible with Aliases
I have some code that looks like this:
InModuleScope MyModule {
Describe "My Class" {
Mock Select-AzureRmSubscription {}
Context 'when calling My Method' {
It 'does a thing' {
Assert-MockCalled Select-AzureRmSubscription
}
}
}
I get the following error:
Describing MyModule
Context when calling My Method
[-]does a thing 40ms
RuntimeException: You did not declare a mock of the Select-AzureRmSubscription Command in module MyModule.
My digging revealed that if I had called Assert-MockCalled Set-AzureRmContext instead, that would have worked
Ah, good point. Mock resolves aliases to their actual command names, but Assert-MockCalled is not currently doing that. Will fix shortly, thanks!
Awesome, thanks!
Fixed in commit 2e2a9c37. I pushed straight to master instead of doing a PR.
Awesome, thanks! Do you know when the next version of Pester will be published, so I can get this fix through "Update-Module"?
Probably tonight. We've got quite a bit of unreleased stuff in the master branch now, so it's just about time for another publish.
Done, 3.3.12 is published.