@@ -420,21 +420,17 @@ mod tests {
420
420
setup_test_index ( & client, & index) . await ?;
421
421
index
422
422
. set_filterable_attributes ( [ "id" ] )
423
- . await
424
- . unwrap ( )
423
+ . await ?
425
424
. wait_for_completion ( & client, None , None )
426
- . await
427
- . unwrap ( ) ;
425
+ . await ? ;
426
+
428
427
let mut query = DocumentDeletionQuery :: new ( & index) ;
429
428
query. with_filter ( "id = 1" ) ;
430
-
431
429
index
432
430
. delete_documents_with ( & query)
433
- . await
434
- . unwrap ( )
431
+ . await ?
435
432
. wait_for_completion ( & client, None , None )
436
- . await
437
- . unwrap ( ) ;
433
+ . await ?;
438
434
let document_result = index. get_document :: < MyObject > ( "1" ) . await ;
439
435
440
436
match document_result {
@@ -450,6 +446,62 @@ mod tests {
450
446
Ok ( ( ) )
451
447
}
452
448
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
+
453
505
#[ meilisearch_test]
454
506
async fn test_get_documents_with_only_one_param (
455
507
client : Client ,
0 commit comments