pub struct TestResponse {
pub response: Response<Body>,
pub body_bytes: Vec<u8>,
}Expand description
Representasi Response pengujian dengan 20+ fluent assertions
Fields§
§response: Response<Body>§body_bytes: Vec<u8>Implementations§
Source§impl TestResponse
impl TestResponse
pub async fn new(response: Response<Body>) -> TestResponse
pub fn status(&self) -> StatusCode
pub fn assert_status<T>(&self, expected: T) -> &TestResponsewhere
T: IntoStatusCode,
pub fn assert_ok(&self) -> &TestResponse
pub fn assert_created(&self) -> &TestResponse
pub fn assert_accepted(&self) -> &TestResponse
pub fn assert_no_content(&self) -> &TestResponse
pub fn assert_bad_request(&self) -> &TestResponse
pub fn assert_forbidden(&self) -> &TestResponse
pub fn assert_not_found(&self) -> &TestResponse
pub fn assert_unprocessable(&self) -> &TestResponse
pub fn assert_server_error(&self) -> &TestResponse
pub fn json(&self) -> Value
Sourcepub fn json_path(&self, path: &str) -> Option<Value>
pub fn json_path(&self, path: &str) -> Option<Value>
Evaluasi nilai JSON pada path tertentu menggunakan dot notation (misal: “data.user.name” atau “items[0].id”)
pub fn assert_json_path( &self, path: &str, expected: impl Into<Value>, ) -> &TestResponse
pub fn assert_json_has(&self, path: &str) -> &TestResponse
pub fn assert_json_missing(&self, path: &str) -> &TestResponse
pub fn assert_json_count( &self, path: &str, expected_count: usize, ) -> &TestResponse
pub fn text(&self) -> String
pub fn assert_see(&self, text: &str) -> &TestResponse
pub fn assert_dont_see(&self, text: &str) -> &TestResponse
pub fn assert_header(&self, key: &str, expected: &str) -> &TestResponse
pub fn assert_header_missing(&self, key: &str) -> &TestResponse
pub fn assert_redirect(&self, expected_location: &str) -> &TestResponse
Auto Trait Implementations§
impl !RefUnwindSafe for TestResponse
impl !Sync for TestResponse
impl !UnwindSafe for TestResponse
impl Forget for TestResponse
impl Freeze for TestResponse
impl Move for TestResponse
impl Send for TestResponse
impl Unpin for TestResponse
impl UnsafeUnpin for TestResponse
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> 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