pub struct FakeHttp(/* private fields */);Expand description
The fake behind state.http in tests; from Http::fake or
TestApp::fake_http.
Implementations§
Source§impl FakeHttp
impl FakeHttp
Sourcepub fn on(&self, pattern: &str, response: FakeResponse) -> &Self
pub fn on(&self, pattern: &str, response: FakeResponse) -> &Self
Answers requests matching pattern with response. The pattern is a
URL where * matches anything, optionally after a method
("POST https://api.example.com/orders"). Several answers for one
pattern are given in turn; the last one repeats.
Sourcepub fn sent(&self) -> Vec<SentRequest>
pub fn sent(&self) -> Vec<SentRequest>
The requests sent so far, oldest first.
Sourcepub fn assert_sent(&self, check: impl Fn(&SentRequest) -> bool)
pub fn assert_sent(&self, check: impl Fn(&SentRequest) -> bool)
Panics unless a sent request matches.
Sourcepub fn assert_not_sent(&self, check: impl Fn(&SentRequest) -> bool)
pub fn assert_not_sent(&self, check: impl Fn(&SentRequest) -> bool)
Panics if a sent request matches.
Sourcepub fn assert_sent_count(&self, expected: usize)
pub fn assert_sent_count(&self, expected: usize)
Panics unless exactly expected requests were sent.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FakeHttp
impl RefUnwindSafe for FakeHttp
impl Send for FakeHttp
impl Sync for FakeHttp
impl Unpin for FakeHttp
impl UnsafeUnpin for FakeHttp
impl UnwindSafe for FakeHttp
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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