pub struct MockHttpTransport { /* private fields */ }Expand description
An HttpTransport that returns queued responses and records the requests
it was given. Queue responses with MockHttpTransport::push_response /
push_json / push_error;
they are returned FIFO.
Implementations§
Source§impl MockHttpTransport
impl MockHttpTransport
Sourcepub fn new() -> MockHttpTransport
pub fn new() -> MockHttpTransport
An empty mock.
Sourcepub fn push_response(&self, response: HttpResponse)
pub fn push_response(&self, response: HttpResponse)
Queue a successful response.
Sourcepub fn push_json(&self, status: u16, body: impl Into<String>)
pub fn push_json(&self, status: u16, body: impl Into<String>)
Queue a response from a status code and JSON body.
Sourcepub fn push_error(&self, error: Error)
pub fn push_error(&self, error: Error)
Queue a transport-level error.
Sourcepub fn recorded_requests(&self) -> Vec<HttpRequest>
pub fn recorded_requests(&self) -> Vec<HttpRequest>
The requests executed so far, in order.
Trait Implementations§
Source§impl Debug for MockHttpTransport
impl Debug for MockHttpTransport
Source§impl Default for MockHttpTransport
impl Default for MockHttpTransport
Source§fn default() -> MockHttpTransport
fn default() -> MockHttpTransport
Returns the “default value” for a type. Read more
Source§impl HttpTransport for MockHttpTransport
impl HttpTransport for MockHttpTransport
Source§fn execute(&self, request: &HttpRequest) -> Result<HttpResponse, Error>
fn execute(&self, request: &HttpRequest) -> Result<HttpResponse, Error>
Execute a request and return the response. Read more
Auto Trait Implementations§
impl !Freeze for MockHttpTransport
impl RefUnwindSafe for MockHttpTransport
impl Send for MockHttpTransport
impl Sync for MockHttpTransport
impl Unpin for MockHttpTransport
impl UnsafeUnpin for MockHttpTransport
impl UnwindSafe for MockHttpTransport
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more