Skip to content
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

Overwrite mocks #94

Open
RichoDemus opened this issue Oct 20, 2023 · 1 comment
Open

Overwrite mocks #94

RichoDemus opened this issue Oct 20, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@RichoDemus
Copy link

RichoDemus commented Oct 20, 2023

I'd like the ability to overwrite a previously defined mock if I define a new one with the same "when" like this:

self.mock_server.mock(|when, then| {
when.method(GET)
.path("/api/"));
then.status(200).json_body(json!({
"msg": "A"
}));
});

now a call to /api returns msg: A

then I do
self.mock_server.mock(|when, then| {
when.method(GET)
.path("/api/"));
then.status(200).json_body(json!({
"msg": "B"
}));
});

now a call to /api returns msg:B

currently it seems like the only way is to delete the old mock first which is a bit cumbersome imo

@alexliesenfeld
Copy link
Owner

I see, thanks for your suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants