Open sazzer opened 2 years ago
I can see at least four ways this could be achieved:
MountedMockSet
that unexpected calls should panic instead of returning a 404MountedMockSet
MountedMockSet.verify_all()
panic if it ever encountered any unexpected callsI've no idea which of those would be preferable though.
I've been using approach 1:
Mock::given(any())
.respond_with(|req: &_| panic!("Request did not match any expected requests: {req:#?}"))
.with_priority(u8::MAX)
.mount(&server)
.await;
The produced error isn't great, but you can make do.
Right now, if a
MockServer
receives an unexpected call then this gets logged and anHTTP 404
is returned to the client.It would be useful if there was some way to have the server instead fail tests if it receives an unexpected request. That would not only be more obvious in outputs - especially if the client is expecting a 404 from the server and gets it for the wrong reason - but it also means that, if using WireMock to emulate a real remote service, unexpected API calls to it will be caught quickly.
Cheers