@@ -420,21 +420,17 @@ mod tests {
420420 setup_test_index ( & client, & index) . await ?;
421421 index
422422 . set_filterable_attributes ( [ "id" ] )
423- . await
424- . unwrap ( )
423+ . await ?
425424 . wait_for_completion ( & client, None , None )
426- . await
427- . unwrap ( ) ;
425+ . await ? ;
426+
428427 let mut query = DocumentDeletionQuery :: new ( & index) ;
429428 query. with_filter ( "id = 1" ) ;
430-
431429 index
432430 . delete_documents_with ( & query)
433- . await
434- . unwrap ( )
431+ . await ?
435432 . wait_for_completion ( & client, None , None )
436- . await
437- . unwrap ( ) ;
433+ . await ?;
438434 let document_result = index. get_document :: < MyObject > ( "1" ) . await ;
439435
440436 match document_result {
@@ -450,6 +446,62 @@ mod tests {
450446 Ok ( ( ) )
451447 }
452448
449+ #[ meilisearch_test]
450+ async fn test_delete_documents_with_no_filter (
451+ client : Client ,
452+ index : Index ,
453+ ) -> Result < ( ) , Error > {
454+ setup_test_index ( & client, & index) . await ?;
455+ index
456+ . set_filterable_attributes ( [ "id" ] )
457+ . await ?
458+ . wait_for_completion ( & client, None , None )
459+ . await ?;
460+
461+ let query = DocumentDeletionQuery :: new ( & index) ;
462+ let error = index. delete_documents_with ( & query) . await . unwrap_err ( ) ;
463+
464+ assert ! ( matches!(
465+ error,
466+ Error :: Meilisearch ( MeilisearchError {
467+ error_code: ErrorCode :: InvalidDocumentDeleteFilter ,
468+ error_type: ErrorType :: InvalidRequest ,
469+ ..
470+ } )
471+ ) ) ;
472+
473+ Ok ( ( ) )
474+ }
475+
476+ #[ meilisearch_test]
477+ async fn test_delete_documents_with_filter_not_filterable (
478+ client : Client ,
479+ index : Index ,
480+ ) -> Result < ( ) , Error > {
481+ setup_test_index ( & client, & index) . await ?;
482+
483+ let mut query = DocumentDeletionQuery :: new ( & index) ;
484+ query. with_filter ( "id = 1" ) ;
485+ let error = index
486+ . delete_documents_with ( & query)
487+ . await ?
488+ . wait_for_completion ( & client, None , None )
489+ . await ?;
490+
491+ let error = error. unwrap_failure ( ) ;
492+
493+ assert ! ( matches!(
494+ error,
495+ MeilisearchError {
496+ error_code: ErrorCode :: InvalidDocumentDeleteFilter ,
497+ error_type: ErrorType :: InvalidRequest ,
498+ ..
499+ }
500+ ) ) ;
501+
502+ Ok ( ( ) )
503+ }
504+
453505 #[ meilisearch_test]
454506 async fn test_get_documents_with_only_one_param (
455507 client : Client ,
0 commit comments