-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
How to use the "add stub" API on an existing imposter #106
Comments
MbDotNet does not support the add stub feature currently. You may be able to accomplish your goals with the UpdateImposterAsync client method.
That will result in an imposter with both stubs. This won't work for you if you need to maintain the state of the original stubs (ex. recorded requests) since they'll be replaced. It also won't be helpful if you're trying to add stubs to an imposter that was not created with MbDotNet (ex. saved imposters restored when you started mountebank). |
I just noticed you mentioned it was an existing imposter. The UpdateImposterAsync method will not work then for the reasons I mentioned in my previous reply. Unfortunately, I don't know of any way to accomplish what you are trying to do without updating MbDotNet to support that operation. |
Ok, that's what I figured out. I will try to open a pull request if you are willing to accept that feature. Would you be opened to such a PR? In terms of implementation, given that the What do you think about this? Do you have a better option in mind? |
The This should be a new
The one thing I don't like about that is that
We'll also need a new model to represent the request object:
The client methods will be responsible for creating this request object with the inputs. That way we still get the typing on the public API but can avoid duplicating this model four times. I think the client methods would also call Finally, the client methods will pass the necessary data along to a new method on Let me know if you have any questions or feedback. |
Thanks for the detailed guidance. I agree with your suggestion. I will try to add this in the next few weeks. |
I added support for this in #117. It will be included in the v5 package when I publish it in a few days. |
Thank you so much @mattherman . I was feeling guilty everyday that I saw my post-it reminder to submit such a PR. |
No worries. The v5 package with that functionality has been published: The implementation changed a little bit from what we had discussed. To add a stub to an existing imposter you would do something like this:
|
I have an existing http imposter that is already running in mountebank. I would like to add stub to this imposter by calling the "add stub" API: http://www.mbtest.org/docs/api/overview#add-stub.
I looked in the code of
MbDotNet
but I couldn't find a way to just add a stub to an existing imposter. I just found way to either create or update the imposter.Could you please tell me if I looked in the wrong place or I could call this "add stub" API if this feature exists?
The text was updated successfully, but these errors were encountered: