Struct poem::test::TestResponse
source · [−]pub struct TestResponse(pub Response);
test
only.Expand description
A response object for testing.
Tuple Fields
0: Response
Implementations
sourceimpl TestResponse
impl TestResponse
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_is_not_exist<K>(&self, key: K)where
K: TryInto<HeaderName>,
pub fn assert_header_is_not_exist<K>(&self, key: K)where
K: TryInto<HeaderName>,
Asserts that header key
is not exist.
sourcepub fn assert_header_exist<K>(&self, key: K)where
K: TryInto<HeaderName>,
pub fn assert_header_exist<K>(&self, key: K)where
K: TryInto<HeaderName>,
Asserts that header key
exist.
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_header_csv<K, V, I>(&self, key: K, values: I)where
K: TryInto<HeaderName>,
V: AsRef<str>,
I: IntoIterator<Item = V>,
pub fn assert_header_csv<K, V, I>(&self, key: K, values: I)where
K: TryInto<HeaderName>,
V: AsRef<str>,
I: IntoIterator<Item = V>,
Asserts that the header key
is equal to values
separated by commas.
sourcepub fn assert_header_all<K, V, I>(&self, key: K, values: I)where
K: TryInto<HeaderName>,
V: TryInto<HeaderValue>,
I: IntoIterator<Item = V>,
pub fn assert_header_all<K, V, I>(&self, key: K, values: I)where
K: TryInto<HeaderName>,
V: TryInto<HeaderValue>,
I: IntoIterator<Item = V>,
Asserts that header key
is equals to values
.
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 async fn assert_xml(self, xml: impl Serialize)
pub async fn assert_xml(self, xml: impl Serialize)
Asserts that the response body is XML and it equals to xml
.
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
.