Created
November 23, 2021 10:09
-
-
Save jschmid1/4e67b07ca25ba21fd3aee8eb8e17b429 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- in a it/describe block you can do this to simulate a side-effect | |
| -- similar to python-unittest's side_effect https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.side_effect | |
| local called = false | |
| local side_effect = function() | |
| -- adding a side_effect that causes to fail the `request_uri` the first time | |
| -- but succeed the second time. | |
| if not called then | |
| called = true | |
| return false, "err" | |
| end | |
| return true, nil | |
| end | |
| local s_request_uri = stub(httpc, "request_uri").invokes(side_effect) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment