pub struct Fake { /* private fields */ }Expand description
An HTTP client that replies from a script.
Implementations§
Source§impl Fake
impl Fake
Sourcepub fn reply(self, status: u16, body: &Value) -> Self
pub fn reply(self, status: u16, body: &Value) -> Self
Answer the next request with this status and JSON body.
Sourcepub fn reply_with(self, response: HttpResponse) -> Self
pub fn reply_with(self, response: HttpResponse) -> Self
Answer the next request with exactly this response.
Sourcepub fn sent(&self) -> &[HttpRequest]
pub fn sent(&self) -> &[HttpRequest]
Every request the run made, in order.
Source§impl Fake
A blocking HttpClient that records the waits asked of it instead
of sleeping through them.
impl Fake
A blocking HttpClient that records the waits asked of it instead
of sleeping through them.
crate::execute sleeps on the calling thread, so a test that wants
a retry’s delay counted rather than spent drives crate::Run
itself; this is the recorder it uses.
Trait Implementations§
Source§impl AsyncHttpClient for Fake
impl AsyncHttpClient for Fake
Source§fn sleep(&self, _duration: Duration) -> SleepFuture<'_>
fn sleep(&self, _duration: Duration) -> SleepFuture<'_>
Returns at once: a test should not spend the delay it asserts on.
Source§fn send<'a>(&'a mut self, request: &'a HttpRequest) -> SendFuture<'a>
fn send<'a>(&'a mut self, request: &'a HttpRequest) -> SendFuture<'a>
Send
request and return what came back. Read moreSource§impl HttpClient for Fake
impl HttpClient for Fake
Source§fn send(&mut self, request: &HttpRequest) -> Result<HttpResponse, ClientError>
fn send(&mut self, request: &HttpRequest) -> Result<HttpResponse, ClientError>
Send
request and return what came back. Read moreAuto Trait Implementations§
impl Freeze for Fake
impl RefUnwindSafe for Fake
impl Send for Fake
impl Sync for Fake
impl Unpin for Fake
impl UnsafeUnpin for Fake
impl UnwindSafe for Fake
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more