-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide more examples or test cases #13
Comments
Oh, I see now the tests are added into the |
@davidweterings sorry to ping but could not get any help yet. I'm trying to mock a scenario that a post would return with failure like 500 or 409, is that possible with this library? |
@ahmetoz no worries. You can easily get 409s by sending the wrong version. F.e.:
500's are harder to create/not really the point of this library (which is to mock the CT api). Usually the CT api gives back 400's on invalid or incorrect POST data. I'm not sure what your use case is for specific 500 errors. |
Hey, @davidweterings thanks for the reply 👍🏽 I saw that kind of scenario in test files, but if I am sending the request inside my code and not in the test, can I mock those requests by using the library? I think mocking the usual scenarios within the library looks nice and covers most API calls, but in unit tests, we also need to ensure cases such as reasoning the code flow in the exception handlers. I could only see that all requests are backed by in-memory storage and those are mocked already as successful, do you see any way to mock requests? |
@ahmetoz we're still figuring out what to use this for and what cases we can / should handle. If you have a suggestion/concrete example (and a PR ;)?) we can take a look. I can imagine something like this where you explicitly tell ctMock what the next response should be like. This could then possilby also be used to delay responses, fake timeouts.
|
Hi, @davidweterings as explained this scenario could be anything you want to unit test the exception flow, for instance you have a logic that you want to update actions with the correct version when API fails with 409. So manipulating the nock instance with a ctMock callback would be nice to have, unfortunately, I don't have time to prepare a PR for that, as I am not really familiar with the library and this looks like a core change. Here your proposal with |
Hey,
The library looks interesting and might help us to reduce lots of boilerplate test code.
I tried the example in the readme but unfortunately, it did not work for me, could you provide more examples of how it could be used, I could not see any tests in a project to inspire.
Regards, Ahmet.
The text was updated successfully, but these errors were encountered: