Replies: 1 comment
-
As long as In other words, if you create any mocks inside a Personally I'd write a simple MyTestHelpers-module that you'd import before running |
Beta Was this translation helpful? Give feedback.
-
As long as In other words, if you create any mocks inside a Personally I'd write a simple MyTestHelpers-module that you'd import before running |
Beta Was this translation helpful? Give feedback.
-
I'm doing a bunch of unit tests for module functions that are essentially 1-to-1 wrappers for REST method calls. One requirement is that we don't want request URLs to show up on VERBOSE stream, so the unit tests check that
Invoke-RestMethod
is always called with an explicit-Verbose:$false
parameter.For that purpose, I've written a small reusable mock (gets dot-sourced in each unit test file):
This works fine.
Now, we have a few module functions that wrap several
Invoke-RestMethod
calls (e.g. get some data, do something with it,PUT
it back), which means I need custom mocks for those calls (need to return some mock data).While it's simple to copy that one line from our "default"
Invoke-RestMethod
mock, I've also tried this:I wasn't expecting it to work - but it did!
Is this expected? Supported? Should I use it (not much of a DRY code improvement in this particular case, but the "default" mock could contain more complex code).
Beta Was this translation helpful? Give feedback.
All reactions