make the new_shared function synchronous and stop indexing documents when it's not required

This commit is contained in:
Tamo 2024-07-18 17:26:43 +02:00
parent e5345fb0eb
commit 953d3a44bd
8 changed files with 130 additions and 183 deletions

View File

@ -51,7 +51,7 @@ impl Server {
Server { service, _dir: Some(dir) } Server { service, _dir: Some(dir) }
} }
pub async fn new_shared() -> &'static Self { pub fn new_shared() -> &'static Self {
&TEST_SHARED_INSTANCE &TEST_SHARED_INSTANCE
} }

View File

@ -6,7 +6,7 @@ use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn get_all_documents_bad_offset() { async fn get_all_documents_bad_offset() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.get_all_documents_raw("?offset").await; let (response, code) = index.get_all_documents_raw("?offset").await;
@ -45,7 +45,7 @@ async fn get_all_documents_bad_offset() {
#[actix_rt::test] #[actix_rt::test]
async fn get_all_documents_bad_limit() { async fn get_all_documents_bad_limit() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.get_all_documents_raw("?limit").await; let (response, code) = index.get_all_documents_raw("?limit").await;
@ -84,7 +84,7 @@ async fn get_all_documents_bad_limit() {
#[actix_rt::test] #[actix_rt::test]
async fn get_all_documents_bad_filter() { async fn get_all_documents_bad_filter() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
// Since the filter can't be parsed automatically by deserr, we have the wrong error message // Since the filter can't be parsed automatically by deserr, we have the wrong error message
@ -162,7 +162,7 @@ async fn get_all_documents_bad_filter() {
#[actix_rt::test] #[actix_rt::test]
async fn delete_documents_batch() { async fn delete_documents_batch() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.delete_batch_raw(json!("doggo")).await; let (response, code) = index.delete_batch_raw(json!("doggo")).await;
@ -179,7 +179,7 @@ async fn delete_documents_batch() {
#[actix_rt::test] #[actix_rt::test]
async fn replace_documents_missing_payload() { async fn replace_documents_missing_payload() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = let (response, code) =
@ -221,7 +221,7 @@ async fn replace_documents_missing_payload() {
#[actix_rt::test] #[actix_rt::test]
async fn update_documents_missing_payload() { async fn update_documents_missing_payload() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.raw_update_documents("", Some("application/json"), "").await; let (response, code) = index.raw_update_documents("", Some("application/json"), "").await;
@ -260,7 +260,7 @@ async fn update_documents_missing_payload() {
#[actix_rt::test] #[actix_rt::test]
async fn replace_documents_missing_content_type() { async fn replace_documents_missing_content_type() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.raw_add_documents("", Vec::new(), "").await; let (response, code) = index.raw_add_documents("", Vec::new(), "").await;
@ -289,7 +289,7 @@ async fn replace_documents_missing_content_type() {
#[actix_rt::test] #[actix_rt::test]
async fn update_documents_missing_content_type() { async fn update_documents_missing_content_type() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.raw_update_documents("", None, "").await; let (response, code) = index.raw_update_documents("", None, "").await;
@ -318,7 +318,7 @@ async fn update_documents_missing_content_type() {
#[actix_rt::test] #[actix_rt::test]
async fn replace_documents_bad_content_type() { async fn replace_documents_bad_content_type() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.raw_add_documents("", vec![("Content-Type", "doggo")], "").await; let (response, code) = index.raw_add_documents("", vec![("Content-Type", "doggo")], "").await;
@ -335,7 +335,7 @@ async fn replace_documents_bad_content_type() {
#[actix_rt::test] #[actix_rt::test]
async fn update_documents_bad_content_type() { async fn update_documents_bad_content_type() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.raw_update_documents("", Some("doggo"), "").await; let (response, code) = index.raw_update_documents("", Some("doggo"), "").await;
@ -352,7 +352,7 @@ async fn update_documents_bad_content_type() {
#[actix_rt::test] #[actix_rt::test]
async fn replace_documents_bad_csv_delimiter() { async fn replace_documents_bad_csv_delimiter() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index let (response, code) = index
@ -401,7 +401,7 @@ async fn replace_documents_bad_csv_delimiter() {
#[actix_rt::test] #[actix_rt::test]
async fn update_documents_bad_csv_delimiter() { async fn update_documents_bad_csv_delimiter() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = let (response, code) =
@ -448,7 +448,7 @@ async fn update_documents_bad_csv_delimiter() {
#[actix_rt::test] #[actix_rt::test]
async fn replace_documents_csv_delimiter_with_bad_content_type() { async fn replace_documents_csv_delimiter_with_bad_content_type() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index let (response, code) = index
@ -480,7 +480,7 @@ async fn replace_documents_csv_delimiter_with_bad_content_type() {
#[actix_rt::test] #[actix_rt::test]
async fn update_documents_csv_delimiter_with_bad_content_type() { async fn update_documents_csv_delimiter_with_bad_content_type() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = let (response, code) =
@ -510,7 +510,7 @@ async fn update_documents_csv_delimiter_with_bad_content_type() {
#[actix_rt::test] #[actix_rt::test]
async fn delete_document_by_filter() { async fn delete_document_by_filter() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("tests-documents-errors-delete_document_by_filter"); let index = server.index("tests-documents-errors-delete_document_by_filter");
// send a bad payload type // send a bad payload type
@ -674,7 +674,7 @@ async fn delete_document_by_filter() {
#[actix_rt::test] #[actix_rt::test]
async fn fetch_document_by_filter() { async fn fetch_document_by_filter() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("doggo"); let index = server.index("doggo");
index.update_settings_filterable_attributes(json!(["color"])).await; index.update_settings_filterable_attributes(json!(["color"])).await;
index index
@ -771,7 +771,7 @@ async fn fetch_document_by_filter() {
#[actix_rt::test] #[actix_rt::test]
async fn retrieve_vectors() { async fn retrieve_vectors() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("doggo"); let index = server.index("doggo");
// GETALL DOCUMENTS BY QUERY // GETALL DOCUMENTS BY QUERY

View File

@ -5,7 +5,7 @@ use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn get_indexes_bad_offset() { async fn get_indexes_bad_offset() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.list_indexes_raw("?offset=doggo").await; let (response, code) = server.list_indexes_raw("?offset=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -21,7 +21,7 @@ async fn get_indexes_bad_offset() {
#[actix_rt::test] #[actix_rt::test]
async fn get_indexes_bad_limit() { async fn get_indexes_bad_limit() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.list_indexes_raw("?limit=doggo").await; let (response, code) = server.list_indexes_raw("?limit=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -37,7 +37,7 @@ async fn get_indexes_bad_limit() {
#[actix_rt::test] #[actix_rt::test]
async fn get_indexes_unknown_field() { async fn get_indexes_unknown_field() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.list_indexes_raw("?doggo=nolimit").await; let (response, code) = server.list_indexes_raw("?doggo=nolimit").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -53,7 +53,7 @@ async fn get_indexes_unknown_field() {
#[actix_rt::test] #[actix_rt::test]
async fn create_index_missing_uid() { async fn create_index_missing_uid() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.create_index(json!({ "primaryKey": "doggo" })).await; let (response, code) = server.create_index(json!({ "primaryKey": "doggo" })).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -69,7 +69,7 @@ async fn create_index_missing_uid() {
#[actix_rt::test] #[actix_rt::test]
async fn create_index_bad_uid() { async fn create_index_bad_uid() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.create_index(json!({ "uid": "the best doggo" })).await; let (response, code) = server.create_index(json!({ "uid": "the best doggo" })).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -96,7 +96,7 @@ async fn create_index_bad_uid() {
#[actix_rt::test] #[actix_rt::test]
async fn create_index_bad_primary_key() { async fn create_index_bad_primary_key() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server let (response, code) = server
.create_index(json!({ "uid": "doggo", "primaryKey": ["the", "best", "doggo"] })) .create_index(json!({ "uid": "doggo", "primaryKey": ["the", "best", "doggo"] }))
@ -114,7 +114,7 @@ async fn create_index_bad_primary_key() {
#[actix_rt::test] #[actix_rt::test]
async fn create_index_unknown_field() { async fn create_index_unknown_field() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.create_index(json!({ "uid": "doggo", "doggo": "bernese" })).await; let (response, code) = server.create_index(json!({ "uid": "doggo", "doggo": "bernese" })).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -130,7 +130,7 @@ async fn create_index_unknown_field() {
#[actix_rt::test] #[actix_rt::test]
async fn get_index_bad_uid() { async fn get_index_bad_uid() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("the good doggo"); let index = server.index("the good doggo");
let (response, code) = index.get().await; let (response, code) = index.get().await;
@ -147,7 +147,7 @@ async fn get_index_bad_uid() {
#[actix_rt::test] #[actix_rt::test]
async fn update_index_bad_primary_key() { async fn update_index_bad_primary_key() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("doggo"); let index = server.index("doggo");
let (response, code) = index.update_raw(json!({ "primaryKey": ["doggo"] })).await; let (response, code) = index.update_raw(json!({ "primaryKey": ["doggo"] })).await;
@ -164,7 +164,7 @@ async fn update_index_bad_primary_key() {
#[actix_rt::test] #[actix_rt::test]
async fn update_index_immutable_uid() { async fn update_index_immutable_uid() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("doggo"); let index = server.index("doggo");
let (response, code) = index.update_raw(json!({ "uid": "doggo" })).await; let (response, code) = index.update_raw(json!({ "uid": "doggo" })).await;
@ -181,7 +181,7 @@ async fn update_index_immutable_uid() {
#[actix_rt::test] #[actix_rt::test]
async fn update_index_immutable_created_at() { async fn update_index_immutable_created_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("doggo"); let index = server.index("doggo");
let (response, code) = index.update_raw(json!({ "createdAt": "doggo" })).await; let (response, code) = index.update_raw(json!({ "createdAt": "doggo" })).await;
@ -198,7 +198,7 @@ async fn update_index_immutable_created_at() {
#[actix_rt::test] #[actix_rt::test]
async fn update_index_immutable_updated_at() { async fn update_index_immutable_updated_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("doggo"); let index = server.index("doggo");
let (response, code) = index.update_raw(json!({ "updatedAt": "doggo" })).await; let (response, code) = index.update_raw(json!({ "updatedAt": "doggo" })).await;
@ -215,7 +215,7 @@ async fn update_index_immutable_updated_at() {
#[actix_rt::test] #[actix_rt::test]
async fn update_index_unknown_field() { async fn update_index_unknown_field() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("doggo"); let index = server.index("doggo");
let (response, code) = index.update_raw(json!({ "doggo": "bork" })).await; let (response, code) = index.update_raw(json!({ "doggo": "bork" })).await;
@ -232,7 +232,7 @@ async fn update_index_unknown_field() {
#[actix_rt::test] #[actix_rt::test]
async fn update_index_bad_uid() { async fn update_index_bad_uid() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("the good doggo"); let index = server.index("the good doggo");
let (response, code) = index.update_raw(json!({ "primaryKey": "doggo" })).await; let (response, code) = index.update_raw(json!({ "primaryKey": "doggo" })).await;
@ -249,7 +249,7 @@ async fn update_index_bad_uid() {
#[actix_rt::test] #[actix_rt::test]
async fn delete_index_bad_uid() { async fn delete_index_bad_uid() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("the good doggo"); let index = server.index("the good doggo");
let (response, code) = index.delete().await; let (response, code) = index.delete().await;

View File

@ -5,7 +5,7 @@ use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn logs_stream_bad_target() { async fn logs_stream_bad_target() {
let server = Server::new_shared().await; let server = Server::new_shared();
// Wrong type // Wrong type
let (response, code) = server.service.post("/logs/stream", json!({ "target": true })).await; let (response, code) = server.service.post("/logs/stream", json!({ "target": true })).await;
@ -58,7 +58,7 @@ async fn logs_stream_bad_target() {
#[actix_rt::test] #[actix_rt::test]
async fn logs_stream_bad_mode() { async fn logs_stream_bad_mode() {
let server = Server::new_shared().await; let server = Server::new_shared();
// Wrong type // Wrong type
let (response, code) = server.service.post("/logs/stream", json!({ "mode": true })).await; let (response, code) = server.service.post("/logs/stream", json!({ "mode": true })).await;
@ -99,7 +99,7 @@ async fn logs_stream_bad_mode() {
#[actix_rt::test] #[actix_rt::test]
async fn logs_stream_bad_profile_memory() { async fn logs_stream_bad_profile_memory() {
let server = Server::new_shared().await; let server = Server::new_shared();
// Wrong type // Wrong type
let (response, code) = let (response, code) =
@ -156,7 +156,7 @@ async fn logs_stream_bad_profile_memory() {
#[actix_rt::test] #[actix_rt::test]
async fn logs_stream_without_enabling_the_route() { async fn logs_stream_without_enabling_the_route() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.service.post("/logs/stream", json!({})).await; let (response, code) = server.service.post("/logs/stream", json!({})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");

View File

@ -1,12 +1,11 @@
use meili_snap::*; use meili_snap::*;
use super::DOCUMENTS;
use crate::common::Server; use crate::common::Server;
use crate::json; use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn search_unexisting_index() { async fn search_unexisting_index() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("search_unexisting_index"); let index = server.index("search_unexisting_index");
let expected_response = json!({ let expected_response = json!({
@ -26,7 +25,7 @@ async fn search_unexisting_index() {
#[actix_rt::test] #[actix_rt::test]
async fn search_unexisting_parameter() { async fn search_unexisting_parameter() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index index
@ -39,7 +38,7 @@ async fn search_unexisting_parameter() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_q() { async fn search_bad_q() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"q": ["doggo"]})).await; let (response, code) = index.search_post(json!({"q": ["doggo"]})).await;
@ -57,7 +56,7 @@ async fn search_bad_q() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_offset() { async fn search_bad_offset() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"offset": "doggo"})).await; let (response, code) = index.search_post(json!({"offset": "doggo"})).await;
@ -85,7 +84,7 @@ async fn search_bad_offset() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_limit() { async fn search_bad_limit() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"limit": "doggo"})).await; let (response, code) = index.search_post(json!({"limit": "doggo"})).await;
@ -113,7 +112,7 @@ async fn search_bad_limit() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_page() { async fn search_bad_page() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"page": "doggo"})).await; let (response, code) = index.search_post(json!({"page": "doggo"})).await;
@ -141,7 +140,7 @@ async fn search_bad_page() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_hits_per_page() { async fn search_bad_hits_per_page() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"hitsPerPage": "doggo"})).await; let (response, code) = index.search_post(json!({"hitsPerPage": "doggo"})).await;
@ -169,7 +168,7 @@ async fn search_bad_hits_per_page() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_attributes_to_retrieve() { async fn search_bad_attributes_to_retrieve() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"attributesToRetrieve": "doggo"})).await; let (response, code) = index.search_post(json!({"attributesToRetrieve": "doggo"})).await;
@ -187,7 +186,7 @@ async fn search_bad_attributes_to_retrieve() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_retrieve_vectors() { async fn search_bad_retrieve_vectors() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"retrieveVectors": "doggo"})).await; let (response, code) = index.search_post(json!({"retrieveVectors": "doggo"})).await;
@ -237,7 +236,7 @@ async fn search_bad_retrieve_vectors() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_attributes_to_crop() { async fn search_bad_attributes_to_crop() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"attributesToCrop": "doggo"})).await; let (response, code) = index.search_post(json!({"attributesToCrop": "doggo"})).await;
@ -255,7 +254,7 @@ async fn search_bad_attributes_to_crop() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_crop_length() { async fn search_bad_crop_length() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"cropLength": "doggo"})).await; let (response, code) = index.search_post(json!({"cropLength": "doggo"})).await;
@ -283,7 +282,7 @@ async fn search_bad_crop_length() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_attributes_to_highlight() { async fn search_bad_attributes_to_highlight() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"attributesToHighlight": "doggo"})).await; let (response, code) = index.search_post(json!({"attributesToHighlight": "doggo"})).await;
@ -303,7 +302,7 @@ async fn search_bad_attributes_to_highlight() {
async fn search_bad_filter() { async fn search_bad_filter() {
// Since a filter is deserialized as a json Value it will never fail to deserialize. // Since a filter is deserialized as a json Value it will never fail to deserialize.
// Thus the error message is not generated by deserr but written by us. // Thus the error message is not generated by deserr but written by us.
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
// Also, to trigger the error message we need to effectively create the index or else it'll throw an // Also, to trigger the error message we need to effectively create the index or else it'll throw an
// index does not exists error. // index does not exists error.
@ -325,7 +324,7 @@ async fn search_bad_filter() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_sort() { async fn search_bad_sort() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"sort": "doggo"})).await; let (response, code) = index.search_post(json!({"sort": "doggo"})).await;
@ -343,7 +342,7 @@ async fn search_bad_sort() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_show_matches_position() { async fn search_bad_show_matches_position() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"showMatchesPosition": "doggo"})).await; let (response, code) = index.search_post(json!({"showMatchesPosition": "doggo"})).await;
@ -371,7 +370,7 @@ async fn search_bad_show_matches_position() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_facets() { async fn search_bad_facets() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"facets": "doggo"})).await; let (response, code) = index.search_post(json!({"facets": "doggo"})).await;
@ -389,7 +388,7 @@ async fn search_bad_facets() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_threshold() { async fn search_bad_threshold() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"rankingScoreThreshold": "doggo"})).await; let (response, code) = index.search_post(json!({"rankingScoreThreshold": "doggo"})).await;
@ -406,7 +405,7 @@ async fn search_bad_threshold() {
#[actix_rt::test] #[actix_rt::test]
async fn search_invalid_threshold() { async fn search_invalid_threshold() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"rankingScoreThreshold": 42})).await; let (response, code) = index.search_post(json!({"rankingScoreThreshold": 42})).await;
@ -423,7 +422,7 @@ async fn search_invalid_threshold() {
#[actix_rt::test] #[actix_rt::test]
async fn search_non_filterable_facets() { async fn search_non_filterable_facets() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (response, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
// Wait for the settings update to complete // Wait for the settings update to complete
@ -454,7 +453,7 @@ async fn search_non_filterable_facets() {
#[actix_rt::test] #[actix_rt::test]
async fn search_non_filterable_facets_multiple_filterable() { async fn search_non_filterable_facets_multiple_filterable() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, _code) = let (response, _code) =
index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await; index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await;
@ -485,7 +484,7 @@ async fn search_non_filterable_facets_multiple_filterable() {
#[actix_rt::test] #[actix_rt::test]
async fn search_non_filterable_facets_no_filterable() { async fn search_non_filterable_facets_no_filterable() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, _code) = index.update_settings(json!({"filterableAttributes": []})).await; let (response, _code) = index.update_settings(json!({"filterableAttributes": []})).await;
index.wait_task(response.uid()).await.succeeded(); index.wait_task(response.uid()).await.succeeded();
@ -515,7 +514,7 @@ async fn search_non_filterable_facets_no_filterable() {
#[actix_rt::test] #[actix_rt::test]
async fn search_non_filterable_facets_multiple_facets() { async fn search_non_filterable_facets_multiple_facets() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, _uid) = let (response, _uid) =
index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await; index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await;
@ -546,7 +545,7 @@ async fn search_non_filterable_facets_multiple_facets() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_highlight_pre_tag() { async fn search_bad_highlight_pre_tag() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"highlightPreTag": ["doggo"]})).await; let (response, code) = index.search_post(json!({"highlightPreTag": ["doggo"]})).await;
@ -564,7 +563,7 @@ async fn search_bad_highlight_pre_tag() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_highlight_post_tag() { async fn search_bad_highlight_post_tag() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"highlightPostTag": ["doggo"]})).await; let (response, code) = index.search_post(json!({"highlightPostTag": ["doggo"]})).await;
@ -582,7 +581,7 @@ async fn search_bad_highlight_post_tag() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_crop_marker() { async fn search_bad_crop_marker() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"cropMarker": ["doggo"]})).await; let (response, code) = index.search_post(json!({"cropMarker": ["doggo"]})).await;
@ -600,7 +599,7 @@ async fn search_bad_crop_marker() {
#[actix_rt::test] #[actix_rt::test]
async fn search_bad_matching_strategy() { async fn search_bad_matching_strategy() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (response, code) = index.search_post(json!({"matchingStrategy": "doggo"})).await; let (response, code) = index.search_post(json!({"matchingStrategy": "doggo"})).await;
@ -639,13 +638,10 @@ async fn search_bad_matching_strategy() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_invalid_syntax_object() { async fn filter_invalid_syntax_object() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
index index
@ -665,13 +661,10 @@ async fn filter_invalid_syntax_object() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_invalid_syntax_array() { async fn filter_invalid_syntax_array() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
index index
@ -691,13 +684,10 @@ async fn filter_invalid_syntax_array() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_invalid_syntax_string() { async fn filter_invalid_syntax_string() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -716,13 +706,10 @@ async fn filter_invalid_syntax_string() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_invalid_attribute_array() { async fn filter_invalid_attribute_array() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -741,13 +728,10 @@ async fn filter_invalid_attribute_array() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_invalid_attribute_string() { async fn filter_invalid_attribute_string() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -766,13 +750,10 @@ async fn filter_invalid_attribute_string() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_reserved_geo_attribute_array() { async fn filter_reserved_geo_attribute_array() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -791,13 +772,10 @@ async fn filter_reserved_geo_attribute_array() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_reserved_geo_attribute_string() { async fn filter_reserved_geo_attribute_string() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -816,13 +794,10 @@ async fn filter_reserved_geo_attribute_string() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_reserved_attribute_array() { async fn filter_reserved_attribute_array() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -841,13 +816,10 @@ async fn filter_reserved_attribute_array() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_reserved_attribute_string() { async fn filter_reserved_attribute_string() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -866,13 +838,10 @@ async fn filter_reserved_attribute_string() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_reserved_geo_point_array() { async fn filter_reserved_geo_point_array() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -891,13 +860,10 @@ async fn filter_reserved_geo_point_array() {
#[actix_rt::test] #[actix_rt::test]
async fn filter_reserved_geo_point_string() { async fn filter_reserved_geo_point_string() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; let (task, _code) = index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -916,13 +882,10 @@ async fn filter_reserved_geo_point_string() {
#[actix_rt::test] #[actix_rt::test]
async fn sort_geo_reserved_attribute() { async fn sort_geo_reserved_attribute() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"sortableAttributes": ["id"]})).await; let (task, _code) = index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -946,13 +909,10 @@ async fn sort_geo_reserved_attribute() {
#[actix_rt::test] #[actix_rt::test]
async fn sort_reserved_attribute() { async fn sort_reserved_attribute() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"sortableAttributes": ["id"]})).await; let (task, _code) = index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone();
let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(task.uid()).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
@ -976,13 +936,10 @@ async fn sort_reserved_attribute() {
#[actix_rt::test] #[actix_rt::test]
async fn sort_unsortable_attribute() { async fn sort_unsortable_attribute() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("sort_unsortable_attribute"); let index = server.index("sort_unsortable_attribute");
index.update_settings(json!({"sortableAttributes": ["id"]})).await; let (response, _code) = index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone();
let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(response.uid()).await.succeeded(); index.wait_task(response.uid()).await.succeeded();
let expected_response = json!({ let expected_response = json!({
@ -1006,13 +963,10 @@ async fn sort_unsortable_attribute() {
#[actix_rt::test] #[actix_rt::test]
async fn sort_invalid_syntax() { async fn sort_invalid_syntax() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings(json!({"sortableAttributes": ["id"]})).await; let (response, _code) = index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone();
let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(response.uid()).await.succeeded(); index.wait_task(response.uid()).await.succeeded();
let expected_response = json!({ let expected_response = json!({
@ -1036,17 +990,14 @@ async fn sort_invalid_syntax() {
#[actix_rt::test] #[actix_rt::test]
async fn sort_unset_ranking_rule() { async fn sort_unset_ranking_rule() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index let (response, _code) = index
.update_settings( .update_settings(
json!({"sortableAttributes": ["title"], "rankingRules": ["proximity", "exactness"]}), json!({"sortableAttributes": ["title"], "rankingRules": ["proximity", "exactness"]}),
) )
.await; .await;
let documents = DOCUMENTS.clone();
let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(response.uid()).await.succeeded(); index.wait_task(response.uid()).await.succeeded();
let expected_response = json!({ let expected_response = json!({
@ -1070,12 +1021,10 @@ async fn sort_unset_ranking_rule() {
#[actix_rt::test] #[actix_rt::test]
async fn search_on_unknown_field() { async fn search_on_unknown_field() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings_searchable_attributes(json!(["id", "title"])).await; let (response, _code) =
index.update_settings_searchable_attributes(json!(["id", "title"])).await;
let documents = DOCUMENTS.clone();
let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(response.uid()).await.succeeded(); index.wait_task(response.uid()).await.succeeded();
index index
@ -1098,12 +1047,10 @@ async fn search_on_unknown_field() {
#[actix_rt::test] #[actix_rt::test]
async fn search_on_unknown_field_plus_joker() { async fn search_on_unknown_field_plus_joker() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
index.update_settings_searchable_attributes(json!(["id", "title"])).await; let (response, _code) =
index.update_settings_searchable_attributes(json!(["id", "title"])).await;
let documents = DOCUMENTS.clone();
let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(response.uid()).await.succeeded(); index.wait_task(response.uid()).await.succeeded();
index index
@ -1143,7 +1090,7 @@ async fn search_on_unknown_field_plus_joker() {
#[actix_rt::test] #[actix_rt::test]
async fn distinct_at_search_time() { async fn distinct_at_search_time() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
let (task, _) = index.create(None).await; let (task, _) = index.create(None).await;
index.wait_task(task.uid()).await.succeeded(); index.wait_task(task.uid()).await.succeeded();
@ -1207,7 +1154,7 @@ async fn distinct_at_search_time() {
async fn search_with_contains_without_enabling_the_feature() { async fn search_with_contains_without_enabling_the_feature() {
// Since a filter is deserialized as a json Value it will never fail to deserialize. // Since a filter is deserialized as a json Value it will never fail to deserialize.
// Thus the error message is not generated by deserr but written by us. // Thus the error message is not generated by deserr but written by us.
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.unique_index(); let index = server.unique_index();
// Also, to trigger the error message we need to effectively create the index or else it'll throw an // Also, to trigger the error message we need to effectively create the index or else it'll throw an
// index does not exists error. // index does not exists error.

View File

@ -5,7 +5,7 @@ use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_displayed_attributes() { async fn settings_bad_displayed_attributes() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "displayedAttributes": "doggo" })).await; let (response, code) = index.update_settings(json!({ "displayedAttributes": "doggo" })).await;
@ -33,7 +33,7 @@ async fn settings_bad_displayed_attributes() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_searchable_attributes() { async fn settings_bad_searchable_attributes() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "searchableAttributes": "doggo" })).await; let (response, code) = index.update_settings(json!({ "searchableAttributes": "doggo" })).await;
@ -61,7 +61,7 @@ async fn settings_bad_searchable_attributes() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_filterable_attributes() { async fn settings_bad_filterable_attributes() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "filterableAttributes": "doggo" })).await; let (response, code) = index.update_settings(json!({ "filterableAttributes": "doggo" })).await;
@ -89,7 +89,7 @@ async fn settings_bad_filterable_attributes() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_sortable_attributes() { async fn settings_bad_sortable_attributes() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "sortableAttributes": "doggo" })).await; let (response, code) = index.update_settings(json!({ "sortableAttributes": "doggo" })).await;
@ -117,7 +117,7 @@ async fn settings_bad_sortable_attributes() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_ranking_rules() { async fn settings_bad_ranking_rules() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "rankingRules": "doggo" })).await; let (response, code) = index.update_settings(json!({ "rankingRules": "doggo" })).await;
@ -145,7 +145,7 @@ async fn settings_bad_ranking_rules() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_stop_words() { async fn settings_bad_stop_words() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "stopWords": "doggo" })).await; let (response, code) = index.update_settings(json!({ "stopWords": "doggo" })).await;
@ -173,7 +173,7 @@ async fn settings_bad_stop_words() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_synonyms() { async fn settings_bad_synonyms() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "synonyms": "doggo" })).await; let (response, code) = index.update_settings(json!({ "synonyms": "doggo" })).await;
@ -201,7 +201,7 @@ async fn settings_bad_synonyms() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_distinct_attribute() { async fn settings_bad_distinct_attribute() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "distinctAttribute": ["doggo"] })).await; let (response, code) = index.update_settings(json!({ "distinctAttribute": ["doggo"] })).await;
@ -229,7 +229,7 @@ async fn settings_bad_distinct_attribute() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_typo_tolerance() { async fn settings_bad_typo_tolerance() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "typoTolerance": "doggo" })).await; let (response, code) = index.update_settings(json!({ "typoTolerance": "doggo" })).await;
@ -284,7 +284,7 @@ async fn settings_bad_typo_tolerance() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_faceting() { async fn settings_bad_faceting() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "faceting": "doggo" })).await; let (response, code) = index.update_settings(json!({ "faceting": "doggo" })).await;
@ -312,7 +312,7 @@ async fn settings_bad_faceting() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_pagination() { async fn settings_bad_pagination() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "pagination": "doggo" })).await; let (response, code) = index.update_settings(json!({ "pagination": "doggo" })).await;
@ -340,7 +340,7 @@ async fn settings_bad_pagination() {
#[actix_rt::test] #[actix_rt::test]
async fn settings_bad_search_cutoff_ms() { async fn settings_bad_search_cutoff_ms() {
let server = Server::new_shared().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.index("test");
let (response, code) = index.update_settings(json!({ "searchCutoffMs": "doggo" })).await; let (response, code) = index.update_settings(json!({ "searchCutoffMs": "doggo" })).await;

View File

@ -5,7 +5,7 @@ use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn swap_indexes_bad_format() { async fn swap_indexes_bad_format() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.index_swap(json!("doggo")).await; let (response, code) = server.index_swap(json!("doggo")).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -32,7 +32,7 @@ async fn swap_indexes_bad_format() {
#[actix_rt::test] #[actix_rt::test]
async fn swap_indexes_bad_indexes() { async fn swap_indexes_bad_indexes() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.index_swap(json!([{ "indexes": "doggo"}])).await; let (response, code) = server.index_swap(json!([{ "indexes": "doggo"}])).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");

View File

@ -4,7 +4,7 @@ use crate::common::Server;
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_uids() { async fn task_bad_uids() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("uids=doggo").await; let (response, code) = server.tasks_filter("uids=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -53,7 +53,7 @@ async fn task_bad_uids() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_canceled_by() { async fn task_bad_canceled_by() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("canceledBy=doggo").await; let (response, code) = server.tasks_filter("canceledBy=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -91,7 +91,7 @@ async fn task_bad_canceled_by() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_types() { async fn task_bad_types() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("types=doggo").await; let (response, code) = server.tasks_filter("types=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -129,7 +129,7 @@ async fn task_bad_types() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_statuses() { async fn task_bad_statuses() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("statuses=doggo").await; let (response, code) = server.tasks_filter("statuses=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -167,7 +167,7 @@ async fn task_bad_statuses() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_index_uids() { async fn task_bad_index_uids() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("indexUids=the%20good%20doggo").await; let (response, code) = server.tasks_filter("indexUids=the%20good%20doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -205,7 +205,7 @@ async fn task_bad_index_uids() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_limit() { async fn task_bad_limit() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("limit=doggo").await; let (response, code) = server.tasks_filter("limit=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -243,7 +243,7 @@ async fn task_bad_limit() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_from() { async fn task_bad_from() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("from=doggo").await; let (response, code) = server.tasks_filter("from=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -281,7 +281,7 @@ async fn task_bad_from() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_after_enqueued_at() { async fn task_bad_after_enqueued_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("afterEnqueuedAt=doggo").await; let (response, code) = server.tasks_filter("afterEnqueuedAt=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -319,7 +319,7 @@ async fn task_bad_after_enqueued_at() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_before_enqueued_at() { async fn task_bad_before_enqueued_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("beforeEnqueuedAt=doggo").await; let (response, code) = server.tasks_filter("beforeEnqueuedAt=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -357,7 +357,7 @@ async fn task_bad_before_enqueued_at() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_after_started_at() { async fn task_bad_after_started_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("afterStartedAt=doggo").await; let (response, code) = server.tasks_filter("afterStartedAt=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -395,7 +395,7 @@ async fn task_bad_after_started_at() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_before_started_at() { async fn task_bad_before_started_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("beforeStartedAt=doggo").await; let (response, code) = server.tasks_filter("beforeStartedAt=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -433,7 +433,7 @@ async fn task_bad_before_started_at() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_after_finished_at() { async fn task_bad_after_finished_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("afterFinishedAt=doggo").await; let (response, code) = server.tasks_filter("afterFinishedAt=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -471,7 +471,7 @@ async fn task_bad_after_finished_at() {
#[actix_rt::test] #[actix_rt::test]
async fn task_bad_before_finished_at() { async fn task_bad_before_finished_at() {
let server = Server::new_shared().await; let server = Server::new_shared();
let (response, code) = server.tasks_filter("beforeFinishedAt=doggo").await; let (response, code) = server.tasks_filter("beforeFinishedAt=doggo").await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");