LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
624 stars 72 forks source link

Use MockGuards to expose matched requetsts on mocks #102

Closed felipesere closed 1 year ago

felipesere commented 2 years ago

The current way to interact with wiremock is to setup mocks with expectations (on bodys, headers, paths, etc) and then verify these when the server is dropped. This PR tries to sketch out an alternative interaction model, where mocks capture the requests they matched and then expose them to users for verification. This should help in separating "mock setup" from "mock verification".

LukeMathWalker commented 2 years ago

This looks good to me 👌🏻

felipesere commented 2 years ago

I'm wondering about areas worth potentially extending:

LukeMathWalker commented 2 years ago

I saw that body_json method as a helper - all fields of Request are pub.

LukeMathWalker commented 2 years ago

Is it worth adding the same mechanism to server.register(a_mock)?

That'd be a breaking change that I'd prefer to avoid.

felipesere commented 2 years ago

In that case I'm happy to ship it as is. Do we need more docs on fields or something?

LukeMathWalker commented 1 year ago

I think we are fine 👌🏻