pester / AzureDevOpsExtension

MIT License
27 stars 13 forks source link

Dealing with azure policy exceptions #51

Closed gurdeepsira closed 3 years ago

gurdeepsira commented 3 years ago

Where are you running it?

You can run the extensions in the cloud or on-premise

Version of Extension/Task

I assume it is the currently public version, if you are using an older version on-premises let me know, but the answer will probably involve upgrading to the currently public version

Expected behaviour and actual behaviour

Hi, I have a Pester test in Powershell which basically attempts to create a resource in Azure. The intention is that this will fail because of the policy in place to block it, and this is what I am testing (The failure and Azure Policy error).

However, this is a Powershell exception and thus error, which fails the test (technically the test passes).

Can I change this behaviour?

Steps to reproduce the problem

ChrisLGardner commented 3 years ago

For this case you want to make use of the syntax to test for exceptions, which is to wrap the command in {} and then pipe the result to Should -Throw and handle it that way.

gurdeepsira commented 3 years ago

Could you give an example?

ChrisLGardner commented 3 years ago

The syntax should be like this https://pester.dev/docs/usage/assertions#throw