pub struct ExpectObject { /* private fields */ }Implementations§
Source§impl ExpectObject
impl ExpectObject
pub fn empty(self) -> Self
pub fn not_empty(self) -> Self
Sourcepub fn contains<V>(self, expected_values: V) -> Self
pub fn contains<V>(self, expected_values: V) -> Self
Expect an object containing a subset of the JSON object given.
use axum_test::expect_json;
let server = TestServer::new(Router::new())?;
server.get(&"/user/barrington")
.await
.assert_json(&json!({
"name": "Barrington",
"metadata": expect_json::object().contains(json!({
"name": "Joe",
"age": expect_json::integer().in_range(18..=100),
"email": expect_json::email(),
})),
}));Trait Implementations§
Source§impl Clone for ExpectObject
impl Clone for ExpectObject
Source§fn clone(&self) -> ExpectObject
fn clone(&self) -> ExpectObject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExpectObject
impl Debug for ExpectObject
Source§impl Default for ExpectObject
impl Default for ExpectObject
Source§fn default() -> ExpectObject
fn default() -> ExpectObject
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ExpectObject
impl<'de> Deserialize<'de> for ExpectObject
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl ExpectOp for ExpectObject
impl ExpectOp for ExpectObject
fn on_object( &self, context: &mut Context<'_>, received: &Map<String, Value>, ) -> ExpectOpResult<()>
Source§fn debug_supported_types(&self) -> &'static [JsonType]
fn debug_supported_types(&self) -> &'static [JsonType]
This is optional to implement. This method returns a list of types this is targeting. Read more
fn on_any( &self, context: &mut Context<'_>, received: &Value, ) -> ExpectOpResult<()>
fn on_null(&self, context: &mut Context<'_>) -> ExpectOpResult<()>
fn on_f64(&self, context: &mut Context<'_>, received: f64) -> ExpectOpResult<()>
fn on_u64(&self, context: &mut Context<'_>, received: u64) -> ExpectOpResult<()>
fn on_i64(&self, context: &mut Context<'_>, received: i64) -> ExpectOpResult<()>
fn on_boolean( &self, context: &mut Context<'_>, received: bool, ) -> ExpectOpResult<()>
fn on_string( &self, context: &mut Context<'_>, received: &str, ) -> ExpectOpResult<()>
fn on_array( &self, context: &mut Context<'_>, received: &[Value], ) -> ExpectOpResult<()>
Source§impl From<ExpectObject> for Value
impl From<ExpectObject> for Value
Source§fn from(value: ExpectObject) -> Self
fn from(value: ExpectObject) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ExpectObject
impl PartialEq for ExpectObject
Source§impl Serialize for ExpectObject
impl Serialize for ExpectObject
impl StructuralPartialEq for ExpectObject
Auto Trait Implementations§
impl Freeze for ExpectObject
impl RefUnwindSafe for ExpectObject
impl Send for ExpectObject
impl Sync for ExpectObject
impl Unpin for ExpectObject
impl UnwindSafe for ExpectObject
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