Struct poem::test::TestResponse
source · [−]pub struct TestResponse(_);
test
only.Expand description
A response object for testing.
Implementations
sourceimpl TestResponse
impl TestResponse
sourcepub fn into_inner(self) -> Response
pub fn into_inner(self) -> Response
Consumes this object and returns the Response
.
sourcepub fn assert_status(&self, status: StatusCode)
pub fn assert_status(&self, status: StatusCode)
Asserts that the status code is equals to status
.
sourcepub fn assert_status_is_ok(&self)
pub fn assert_status_is_ok(&self)
Asserts that the status code is 200 OK
.
sourcepub fn assert_header<K, V>(&self, key: K, value: V) where
K: TryInto<HeaderName>,
V: TryInto<HeaderValue>,
pub fn assert_header<K, V>(&self, key: K, value: V) where
K: TryInto<HeaderName>,
V: TryInto<HeaderValue>,
Asserts that header key
is equals to value
.
sourcepub fn assert_content_type(&self, content_type: &str)
pub fn assert_content_type(&self, content_type: &str)
Asserts that content type is equals to content_type
.
sourcepub async fn assert_text(self, text: impl AsRef<str>)
pub async fn assert_text(self, text: impl AsRef<str>)
Asserts that the response body is utf8 string and it equals to text
.
sourcepub async fn assert_bytes(self, bytes: impl AsRef<[u8]>)
pub async fn assert_bytes(self, bytes: impl AsRef<[u8]>)
Asserts that the response body is bytes and it equals to bytes
.
sourcepub async fn assert_json(self, json: impl Serialize)
pub async fn assert_json(self, json: impl Serialize)
Asserts that the response body is JSON and it equals to json
.
sourcepub fn sse_stream(self) -> impl Stream<Item = Event> + Send + Unpin + 'static
pub fn sse_stream(self) -> impl Stream<Item = Event> + Send + Unpin + 'static
Consumes this object and return the SSE events stream.
sourcepub fn typed_sse_stream<T: DeserializeOwned + 'static>(
self
) -> impl Stream<Item = T> + Send + Unpin + 'static
pub fn typed_sse_stream<T: DeserializeOwned + 'static>(
self
) -> impl Stream<Item = T> + Send + Unpin + 'static
Consumes this object and return the SSE events stream which deserialize
the message data to T
.
Auto Trait Implementations
impl !RefUnwindSafe for TestResponse
impl Send for TestResponse
impl Sync for TestResponse
impl Unpin for TestResponse
impl !UnwindSafe for TestResponse
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> FutureExt for T
impl<T> FutureExt for T
sourcefn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
sourcefn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more