pub struct Http;Expand description
Implementations§
Source§impl Http
impl Http
Sourcepub fn get(url: impl Into<String>) -> PendingRequest
pub fn get(url: impl Into<String>) -> PendingRequest
GET url.
Sourcepub fn post(url: impl Into<String>) -> PendingRequest
pub fn post(url: impl Into<String>) -> PendingRequest
POST url.
Sourcepub fn put(url: impl Into<String>) -> PendingRequest
pub fn put(url: impl Into<String>) -> PendingRequest
PUT url.
Sourcepub fn patch(url: impl Into<String>) -> PendingRequest
pub fn patch(url: impl Into<String>) -> PendingRequest
PATCH url.
Sourcepub fn delete(url: impl Into<String>) -> PendingRequest
pub fn delete(url: impl Into<String>) -> PendingRequest
DELETE url.
Sourcepub fn request(
method: impl Into<String>,
url: impl Into<String>,
) -> PendingRequest
pub fn request( method: impl Into<String>, url: impl Into<String>, ) -> PendingRequest
A request with any method.
Sourcepub fn install(transport: Arc<dyn Transport>)
pub fn install(transport: Arc<dyn Transport>)
Install the transport every call uses.
Called once at boot. Calling it again replaces the binding, which is
what fake does.
Sourcepub fn fake() -> Arc<FakeTransport> ⓘ
pub fn fake() -> Arc<FakeTransport> ⓘ
Record every outbound call instead of making it.
Returns the fake, so a test can queue answers:
Http::fake().responding(200, r#"{"ok":true}"#);Nothing reaches the network afterwards, which is the other half of the point: a suite that accidentally calls a real endpoint is a suite that fails when somebody runs it on a train.
Sourcepub fn fake_globally() -> Arc<FakeTransport> ⓘ
pub fn fake_globally() -> Arc<FakeTransport> ⓘ
Record every outbound call in the whole process.
For code that spawns: a task started by the code under test inherits no
thread scope, so fake would not catch its calls.
The trade is that two tests doing this at once overwrite each other, so a suite using it has to run those tests one at a time.
Sourcepub fn faking() -> Arc<FakeTransport> ⓘ
pub fn faking() -> Arc<FakeTransport> ⓘ
Sourcepub fn assert_sent(matches: impl Fn(&RecordedRequest) -> bool)
pub fn assert_sent(matches: impl Fn(&RecordedRequest) -> bool)
Panic unless a matching request was sent. See
FakeTransport::assert_sent.
§Panics
If none matched, or if nothing is faking.
Sourcepub fn assert_not_sent(matches: impl Fn(&RecordedRequest) -> bool)
pub fn assert_not_sent(matches: impl Fn(&RecordedRequest) -> bool)
Sourcepub fn assert_nothing_sent()
pub fn assert_nothing_sent()
Auto Trait Implementations§
impl Freeze for Http
impl RefUnwindSafe for Http
impl Send for Http
impl Sync for Http
impl Unpin for Http
impl UnsafeUnpin for Http
impl UnwindSafe for Http
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
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> ⓘ
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> ⓘ
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