pub struct ExpectedResult<T> {
pub value: Option<T>,
pub status: Option<StatusCode>,
pub headers: HashMap<String, String>,
}Expand description
Result builder for testing server function responses.
This allows building expected results for assertion comparisons.
Fields§
§value: Option<T>The expected value.
status: Option<StatusCode>The expected status code.
headers: HashMap<String, String>Expected headers.
Implementations§
Source§impl<T> ExpectedResult<T>
impl<T> ExpectedResult<T>
Sourcepub fn with_value(self, value: T) -> Self
pub fn with_value(self, value: T) -> Self
Set the expected value.
Sourcepub fn with_status(self, status: StatusCode) -> Self
pub fn with_status(self, status: StatusCode) -> Self
Set the expected status code.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Add an expected header.
Sourcepub fn bad_request(self) -> Self
pub fn bad_request(self) -> Self
Expect a bad request (400) response.
Expect an unauthorized (401) response.
Sourcepub fn internal_error(self) -> Self
pub fn internal_error(self) -> Self
Expect an internal server error (500) response.
Trait Implementations§
Source§impl<T: Clone> Clone for ExpectedResult<T>
impl<T: Clone> Clone for ExpectedResult<T>
Source§fn clone(&self) -> ExpectedResult<T>
fn clone(&self) -> ExpectedResult<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for ExpectedResult<T>
impl<T: Debug> Debug for ExpectedResult<T>
Auto Trait Implementations§
impl<T> Freeze for ExpectedResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for ExpectedResult<T>where
T: RefUnwindSafe,
impl<T> Send for ExpectedResult<T>where
T: Send,
impl<T> Sync for ExpectedResult<T>where
T: Sync,
impl<T> Unpin for ExpectedResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for ExpectedResult<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ExpectedResult<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
Source§fn should_contain_message(&self, expected: &str)where
E: Display,
fn should_contain_message(&self, expected: &str)where
E: Display,
Assert that the error message contains the specified text.
Source§fn should_have_message(&self, expected: &str)where
E: Display,
fn should_have_message(&self, expected: &str)where
E: Display,
Assert that the error message matches exactly.