pub struct ExpectArray { /* private fields */ }Implementations§
Source§impl ExpectArray
impl ExpectArray
pub fn empty(self) -> Self
pub fn not_empty(self) -> Self
pub fn len(self, len: usize) -> Self
pub fn min_len(self, min_len: usize) -> Self
pub fn max_len(self, max_len: usize) -> Self
pub fn contains<I, V>(self, expected_values: I) -> Self
Sourcepub fn all<V>(self, expected: V) -> Self
pub fn all<V>(self, expected: V) -> Self
Expects all values in the array match the expected value.
This can be an exact value, or an ExpectOp.
Note an empty array will match this.
use axum_test::expect_json;
let server = TestServer::new(Router::new())?;
server.get(&"/users")
.await
.assert_json(&json!(expect_json::array().all(
json!({
"name": expect_json::string().not_empty(),
"email": expect_json::email(),
})
)));Sourcepub fn unique(self) -> Self
pub fn unique(self) -> Self
Expects all values in the array are unique. No duplicates.
use axum_test::expect_json;
let server = TestServer::new(Router::new())?;
server.get(&"/users")
.await
.assert_json(&json!({
// expect an array of unique UUIDs
"user_ids": expect_json::array()
.all(expect_json::uuid())
.unique(),
}));Trait Implementations§
Source§impl Clone for ExpectArray
impl Clone for ExpectArray
Source§fn clone(&self) -> ExpectArray
fn clone(&self) -> ExpectArray
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 ExpectArray
impl Debug for ExpectArray
Source§impl Default for ExpectArray
impl Default for ExpectArray
Source§fn default() -> ExpectArray
fn default() -> ExpectArray
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ExpectArray
impl<'de> Deserialize<'de> for ExpectArray
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 ExpectArray
impl ExpectOp for ExpectArray
fn on_array( &self, context: &mut Context<'_>, received: &[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_object( &self, context: &mut Context<'_>, received: &Map<String, Value>, ) -> ExpectOpResult<()>
Source§impl From<ExpectArray> for Value
impl From<ExpectArray> for Value
Source§fn from(value: ExpectArray) -> Self
fn from(value: ExpectArray) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ExpectArray
impl PartialEq for ExpectArray
Source§impl Serialize for ExpectArray
impl Serialize for ExpectArray
impl StructuralPartialEq for ExpectArray
Auto Trait Implementations§
impl Freeze for ExpectArray
impl RefUnwindSafe for ExpectArray
impl Send for ExpectArray
impl Sync for ExpectArray
impl Unpin for ExpectArray
impl UnwindSafe for ExpectArray
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