Closed sr-gi closed 1 year ago
@lipanski how would you feel about something like this? I think the change is pretty minimal.
I've locally tested it against https://github.com/lipanski/mockito/issues/160#issuecomment-1451841112 and it's being consistent with the delays.
@sr-gi this feature is a bit too specific for this crate. instead, is there a way to make the with_body_from_request
block accept futures? seems like using tokio::time::sleep
is the way to go.
I'd argue this is actually something pretty useful for an http mock crate. This lets you simulate network delays for instance, which are pretty common and something you may want your code (as in the one using the mock) to account for.
I don't challenge the use case, but there's already a solution for that (with_body_from_request
) which needs some tuning. I'd like to keep the public interface of this crate fairly minimal, whenever possible.
I'm not fluent enough with futures to make then change then, sorry.
Adds optional delays to mocks
Fixes #31 #64 #160