shave off 15s by providing a shared instance to the integration tests

This commit is contained in:
Tamo 2024-07-18 16:32:50 +02:00
parent 2d9a055fb9
commit e5345fb0eb
20 changed files with 297 additions and 297 deletions

View File

@ -81,6 +81,7 @@ impl Display for Value {
f, f,
"{}", "{}",
json_string!(self, { json_string!(self, {
".uid" => "[uid]",
".enqueuedAt" => "[date]", ".enqueuedAt" => "[date]",
".startedAt" => "[date]", ".startedAt" => "[date]",
".finishedAt" => "[date]", ".finishedAt" => "[date]",

View File

@ -16,6 +16,7 @@ use tempfile::TempDir;
use tokio::time::sleep; use tokio::time::sleep;
use tracing::level_filters::LevelFilter; use tracing::level_filters::LevelFilter;
use tracing_subscriber::Layer; use tracing_subscriber::Layer;
use uuid::Uuid;
use super::index::Index; use super::index::Index;
use super::service::Service; use super::service::Service;
@ -30,8 +31,30 @@ pub struct Server {
} }
pub static TEST_TEMP_DIR: Lazy<TempDir> = Lazy::new(|| TempDir::new().unwrap()); pub static TEST_TEMP_DIR: Lazy<TempDir> = Lazy::new(|| TempDir::new().unwrap());
pub static TEST_SHARED_INSTANCE: Lazy<Server> = Lazy::new(Server::init_new_shared_instance);
impl Server { impl Server {
fn init_new_shared_instance() -> Self {
let dir = TempDir::new().unwrap();
if cfg!(windows) {
std::env::set_var("TMP", TEST_TEMP_DIR.path());
} else {
std::env::set_var("TMPDIR", TEST_TEMP_DIR.path());
}
let options = default_settings(dir.path());
let (index_scheduler, auth) = setup_meilisearch(&options).unwrap();
let service = Service { index_scheduler, auth, options, api_key: None };
Server { service, _dir: Some(dir) }
}
pub async fn new_shared() -> &'static Self {
&TEST_SHARED_INSTANCE
}
pub async fn new() -> Self { pub async fn new() -> Self {
let dir = TempDir::new().unwrap(); let dir = TempDir::new().unwrap();
@ -108,6 +131,12 @@ impl Server {
.await .await
} }
/// Returns a view to an index. There is no guarantee that the index exists.
pub fn unique_index(&self) -> Index<'_> {
let uuid = Uuid::new_v4();
self.index_with_encoder(uuid.to_string(), Encoder::Plain)
}
/// Returns a view to an index. There is no guarantee that the index exists. /// Returns a view to an index. There is no guarantee that the index exists.
pub fn index(&self, uid: impl AsRef<str>) -> Index<'_> { pub fn index(&self, uid: impl AsRef<str>) -> Index<'_> {
self.index_with_encoder(uid, Encoder::Plain) self.index_with_encoder(uid, Encoder::Plain)

View File

@ -1110,7 +1110,7 @@ async fn document_addition_with_huge_int_primary_key() {
snapshot!(response, snapshot!(response,
@r###" @r###"
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1402,7 +1402,7 @@ async fn error_document_field_limit_reached_over_multiple_documents() {
snapshot!(response, snapshot!(response,
@r###" @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1436,7 +1436,7 @@ async fn error_document_field_limit_reached_over_multiple_documents() {
snapshot!(response, snapshot!(response,
@r###" @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1485,7 +1485,7 @@ async fn error_document_field_limit_reached_in_one_nested_document() {
snapshot!(response, snapshot!(response,
@r###" @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1528,7 +1528,7 @@ async fn error_document_field_limit_reached_over_multiple_documents_with_nested_
snapshot!(response, snapshot!(response,
@r###" @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1563,7 +1563,7 @@ async fn error_document_field_limit_reached_over_multiple_documents_with_nested_
snapshot!(response, snapshot!(response,
@r###" @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -2209,7 +2209,7 @@ async fn add_invalid_geo_and_then_settings() {
let ret = index.wait_task(ret.uid()).await; let ret = index.wait_task(ret.uid()).await;
snapshot!(ret, @r###" snapshot!(ret, @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -2231,7 +2231,7 @@ async fn add_invalid_geo_and_then_settings() {
let ret = index.wait_task(ret.uid()).await; let ret = index.wait_task(ret.uid()).await;
snapshot!(ret, @r###" snapshot!(ret, @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",

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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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
@ -123,35 +123,8 @@ async fn get_all_documents_bad_filter() {
} }
"###); "###);
let (response, code) = index.create(None).await; let (response, _code) = index.create(None).await;
snapshot!(code, @"202 Accepted"); server.wait_task(response.uid()).await.succeeded();
snapshot!(json_string!(response, { ".enqueuedAt" => "[date]" }), @r###"
{
"taskUid": 0,
"indexUid": "test",
"status": "enqueued",
"type": "indexCreation",
"enqueuedAt": "[date]"
}
"###);
let response = server.wait_task(0).await;
snapshot!(json_string!(response, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }), @r###"
{
"uid": 0,
"indexUid": "test",
"status": "succeeded",
"type": "indexCreation",
"canceledBy": null,
"details": {
"primaryKey": null
},
"error": null,
"duration": "[duration]",
"enqueuedAt": "[date]",
"startedAt": "[date]",
"finishedAt": "[date]"
}
"###);
let (response, code) = index.get_all_documents_raw("?filter").await; let (response, code) = index.get_all_documents_raw("?filter").await;
snapshot!(code, @"200 OK"); snapshot!(code, @"200 OK");
@ -189,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().await; let server = Server::new_shared().await;
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;
@ -206,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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.index("test");
let (response, code) = let (response, code) =
@ -248,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().await; let server = Server::new_shared().await;
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;
@ -287,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().await; let server = Server::new_shared().await;
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;
@ -316,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().await; let server = Server::new_shared().await;
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;
@ -345,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().await; let server = Server::new_shared().await;
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;
@ -362,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().await; let server = Server::new_shared().await;
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;
@ -379,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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.index("test");
let (response, code) = index let (response, code) = index
@ -428,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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.index("test");
let (response, code) = let (response, code) =
@ -475,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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.index("test");
let (response, code) = index let (response, code) = index
@ -507,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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.index("test");
let (response, code) = let (response, code) =
@ -537,13 +510,13 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("doggo"); let index = server.index("tests-documents-errors-delete_document_by_filter");
// send a bad payload type // send a bad payload type
let (response, code) = index.delete_document_by_filter(json!("hello")).await; let (response, code) = index.delete_document_by_filter(json!("hello")).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###" snapshot!(response, @r###"
{ {
"message": "Invalid value type: expected an object, but found a string: `\"hello\"`", "message": "Invalid value type: expected an object, but found a string: `\"hello\"`",
"code": "bad_request", "code": "bad_request",
@ -555,7 +528,7 @@ async fn delete_document_by_filter() {
// send bad payload type // send bad payload type
let (response, code) = index.delete_document_by_filter(json!({ "filter": true })).await; let (response, code) = index.delete_document_by_filter(json!({ "filter": true })).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###" snapshot!(response, @r###"
{ {
"message": "Invalid syntax for the filter parameter: `expected String, Array, found: true`.", "message": "Invalid syntax for the filter parameter: `expected String, Array, found: true`.",
"code": "invalid_document_filter", "code": "invalid_document_filter",
@ -567,7 +540,7 @@ async fn delete_document_by_filter() {
// send bad filter // send bad filter
let (response, code) = index.delete_document_by_filter(json!({ "filter": "hello"})).await; let (response, code) = index.delete_document_by_filter(json!({ "filter": "hello"})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###" snapshot!(response, @r###"
{ {
"message": "Was expecting an operation `=`, `!=`, `>=`, `>`, `<=`, `<`, `IN`, `NOT IN`, `TO`, `EXISTS`, `NOT EXISTS`, `IS NULL`, `IS NOT NULL`, `IS EMPTY`, `IS NOT EMPTY`, `CONTAINS`, `NOT CONTAINS`, `_geoRadius`, or `_geoBoundingBox` at `hello`.\n1:6 hello", "message": "Was expecting an operation `=`, `!=`, `>=`, `>`, `<=`, `<`, `IN`, `NOT IN`, `TO`, `EXISTS`, `NOT EXISTS`, `IS NULL`, `IS NOT NULL`, `IS EMPTY`, `IS NOT EMPTY`, `CONTAINS`, `NOT CONTAINS`, `_geoRadius`, or `_geoBoundingBox` at `hello`.\n1:6 hello",
"code": "invalid_document_filter", "code": "invalid_document_filter",
@ -579,7 +552,7 @@ async fn delete_document_by_filter() {
// send empty filter // send empty filter
let (response, code) = index.delete_document_by_filter(json!({ "filter": ""})).await; let (response, code) = index.delete_document_by_filter(json!({ "filter": ""})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###" snapshot!(response, @r###"
{ {
"message": "Sending an empty filter is forbidden.", "message": "Sending an empty filter is forbidden.",
"code": "invalid_document_filter", "code": "invalid_document_filter",
@ -591,7 +564,7 @@ async fn delete_document_by_filter() {
// do not send any filter // do not send any filter
let (response, code) = index.delete_document_by_filter(json!({})).await; let (response, code) = index.delete_document_by_filter(json!({})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###" snapshot!(response, @r###"
{ {
"message": "Missing field `filter`", "message": "Missing field `filter`",
"code": "missing_document_filter", "code": "missing_document_filter",
@ -604,11 +577,11 @@ async fn delete_document_by_filter() {
let (response, code) = let (response, code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese"})).await; index.delete_document_by_filter(json!({ "filter": "doggo = bernese"})).await;
snapshot!(code, @"202 Accepted"); snapshot!(code, @"202 Accepted");
let response = server.wait_task(response["taskUid"].as_u64().unwrap()).await; let response = server.wait_task(response.uid()).await;
snapshot!(json_string!(response, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]"}), @r###" snapshot!(response, @r###"
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "tests-documents-errors-delete_document_by_filter",
"status": "failed", "status": "failed",
"type": "documentDeletion", "type": "documentDeletion",
"canceledBy": null, "canceledBy": null,
@ -618,7 +591,7 @@ async fn delete_document_by_filter() {
"originalFilter": "\"doggo = bernese\"" "originalFilter": "\"doggo = bernese\""
}, },
"error": { "error": {
"message": "Index `doggo` not found.", "message": "Index `tests-documents-errors-delete_document_by_filter` not found.",
"code": "index_not_found", "code": "index_not_found",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found" "link": "https://docs.meilisearch.com/errors#index_not_found"
@ -632,17 +605,17 @@ async fn delete_document_by_filter() {
let (response, code) = index.create(None).await; let (response, code) = index.create(None).await;
snapshot!(code, @"202 Accepted"); snapshot!(code, @"202 Accepted");
server.wait_task(response["taskUid"].as_u64().unwrap()).await; server.wait_task(response.uid()).await.succeeded();
// no filterable are set // no filterable are set
let (response, code) = let (response, code) =
index.delete_document_by_filter(json!({ "filter": "doggo = bernese"})).await; index.delete_document_by_filter(json!({ "filter": "doggo = bernese"})).await;
snapshot!(code, @"202 Accepted"); snapshot!(code, @"202 Accepted");
let response = server.wait_task(response["taskUid"].as_u64().unwrap()).await; let response = server.wait_task(response.uid()).await;
snapshot!(json_string!(response, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]"}), @r###" snapshot!(response, @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "tests-documents-errors-delete_document_by_filter",
"status": "failed", "status": "failed",
"type": "documentDeletion", "type": "documentDeletion",
"canceledBy": null, "canceledBy": null,
@ -666,17 +639,17 @@ async fn delete_document_by_filter() {
let (response, code) = index.update_settings_filterable_attributes(json!(["doggo"])).await; let (response, code) = index.update_settings_filterable_attributes(json!(["doggo"])).await;
snapshot!(code, @"202 Accepted"); snapshot!(code, @"202 Accepted");
server.wait_task(response["taskUid"].as_u64().unwrap()).await; server.wait_task(response.uid()).await.succeeded();
// not filterable while there is a filterable attribute // not filterable while there is a filterable attribute
let (response, code) = let (response, code) =
index.delete_document_by_filter(json!({ "filter": "catto = jorts"})).await; index.delete_document_by_filter(json!({ "filter": "catto = jorts"})).await;
snapshot!(code, @"202 Accepted"); snapshot!(code, @"202 Accepted");
let response = server.wait_task(response["taskUid"].as_u64().unwrap()).await; let response = server.wait_task(response.uid()).await;
snapshot!(json_string!(response, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]"}), @r###" snapshot!(response, @r###"
{ {
"uid": 4, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "tests-documents-errors-delete_document_by_filter",
"status": "failed", "status": "failed",
"type": "documentDeletion", "type": "documentDeletion",
"canceledBy": null, "canceledBy": null,
@ -701,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().await; let server = Server::new_shared().await;
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
@ -798,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().await; let server = Server::new_shared().await;
let index = server.index("doggo"); let index = server.index("doggo");
// GETALL DOCUMENTS BY QUERY // GETALL DOCUMENTS BY QUERY

View File

@ -2,7 +2,7 @@
source: meilisearch/tests/dumps/mod.rs source: meilisearch/tests/dumps/mod.rs
--- ---
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "pets", "indexUid": "pets",
"status": "succeeded", "status": "succeeded",
"type": "settingsUpdate", "type": "settingsUpdate",

View File

@ -2,7 +2,7 @@
source: meilisearch/tests/dumps/mod.rs source: meilisearch/tests/dumps/mod.rs
--- ---
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "pets", "indexUid": "pets",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",

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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
// 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().await; let server = Server::new_shared().await;
// 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().await; let server = Server::new_shared().await;
// 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().await; let server = Server::new_shared().await;
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

@ -6,11 +6,11 @@ use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn search_unexisting_index() { async fn search_unexisting_index() {
let server = Server::new().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.index("search_unexisting_index");
let expected_response = json!({ let expected_response = json!({
"message": "Index `test` not found.", "message": "Index `search_unexisting_index` not found.",
"code": "index_not_found", "code": "index_not_found",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found" "link": "https://docs.meilisearch.com/errors#index_not_found"
@ -26,8 +26,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index index
.search(json!({"marin": "hello"}), |response, code| { .search(json!({"marin": "hello"}), |response, code| {
@ -39,8 +39,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -57,8 +57,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -85,8 +85,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -113,8 +113,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -141,8 +141,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -169,8 +169,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -187,8 +187,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -237,8 +237,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -255,8 +255,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -283,8 +283,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -303,14 +303,12 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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.
let (_, code) = index.create(None).await; let (response, _code) = index.create(None).await;
server.wait_task(0).await; server.wait_task(response.uid()).await.succeeded();
snapshot!(code, @"202 Accepted");
let (response, code) = index.search_post(json!({ "filter": true })).await; let (response, code) = index.search_post(json!({ "filter": true })).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -327,8 +325,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -345,8 +343,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -373,8 +371,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -391,8 +389,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -408,8 +406,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -425,11 +423,11 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
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
index.wait_task(0).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await; let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -456,10 +454,11 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
let (response, _code) =
index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await; index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await;
index.wait_task(0).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await; let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -486,10 +485,10 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": []})).await; let (response, _code) = index.update_settings(json!({"filterableAttributes": []})).await;
index.wait_task(0).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await; let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -516,10 +515,11 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
let (response, _uid) =
index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await; index.update_settings(json!({"filterableAttributes": ["title", "genres"]})).await;
index.wait_task(0).await; index.wait_task(response.uid()).await.succeeded();
let (response, code) = index.search_post(json!({"facets": ["doggo", "neko"]})).await; let (response, code) = index.search_post(json!({"facets": ["doggo", "neko"]})).await;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -546,8 +546,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -564,8 +564,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -582,8 +582,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -600,8 +600,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); 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;
snapshot!(code, @"400 Bad Request"); snapshot!(code, @"400 Bad Request");
@ -639,8 +639,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
@ -665,8 +665,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
@ -691,14 +691,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "Found unexpected characters at the end of the filter: `XOR title = Glass`. You probably forgot an `OR` or an `AND` rule.\n15:32 title = Glass XOR title = Glass", "message": "Found unexpected characters at the end of the filter: `XOR title = Glass`. You probably forgot an `OR` or an `AND` rule.\n15:32 title = Glass XOR title = Glass",
@ -716,14 +716,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "Attribute `many` is not filterable. Available filterable attributes are: `title`.\n1:5 many = Glass", "message": "Attribute `many` is not filterable. Available filterable attributes are: `title`.\n1:5 many = Glass",
@ -741,14 +741,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "Attribute `many` is not filterable. Available filterable attributes are: `title`.\n1:5 many = Glass", "message": "Attribute `many` is not filterable. Available filterable attributes are: `title`.\n1:5 many = Glass",
@ -766,14 +766,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geo` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:13 _geo = Glass", "message": "`_geo` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:13 _geo = Glass",
@ -791,14 +791,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geo` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:13 _geo = Glass", "message": "`_geo` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:13 _geo = Glass",
@ -816,14 +816,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geoDistance` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:21 _geoDistance = Glass", "message": "`_geoDistance` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:21 _geoDistance = Glass",
@ -841,14 +841,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geoDistance` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:21 _geoDistance = Glass", "message": "`_geoDistance` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:21 _geoDistance = Glass",
@ -866,14 +866,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:18 _geoPoint = Glass", "message": "`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:18 _geoPoint = Glass",
@ -891,14 +891,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"filterableAttributes": ["title"]})).await; index.update_settings(json!({"filterableAttributes": ["title"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:18 _geoPoint = Glass", "message": "`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:18 _geoPoint = Glass",
@ -916,14 +916,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"sortableAttributes": ["id"]})).await; index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geo` is a reserved keyword and thus can't be used as a sort expression. Use the _geoPoint(latitude, longitude) built-in rule to sort on _geo field coordinates.", "message": "`_geo` is a reserved keyword and thus can't be used as a sort expression. Use the _geoPoint(latitude, longitude) built-in rule to sort on _geo field coordinates.",
@ -946,14 +946,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"sortableAttributes": ["id"]})).await; index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (task, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(task.uid()).await;
let expected_response = json!({ let expected_response = json!({
"message": "`_geoDistance` is a reserved keyword and thus can't be used as a sort expression.", "message": "`_geoDistance` is a reserved keyword and thus can't be used as a sort expression.",
@ -976,14 +976,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.index("sort_unsortable_attribute");
index.update_settings(json!({"sortableAttributes": ["id"]})).await; index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await.succeeded();
let expected_response = json!({ let expected_response = json!({
"message": "Attribute `title` is not sortable. Available sortable attributes are: `id`.", "message": "Attribute `title` is not sortable. Available sortable attributes are: `id`.",
@ -1006,14 +1006,14 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({"sortableAttributes": ["id"]})).await; index.update_settings(json!({"sortableAttributes": ["id"]})).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await.succeeded();
let expected_response = json!({ let expected_response = json!({
"message": "Invalid syntax for the sort parameter: expected expression ending by `:asc` or `:desc`, found `title`.", "message": "Invalid syntax for the sort parameter: expected expression ending by `:asc` or `:desc`, found `title`.",
@ -1036,8 +1036,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index index
.update_settings( .update_settings(
@ -1046,8 +1046,8 @@ async fn sort_unset_ranking_rule() {
.await; .await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await.succeeded();
let expected_response = json!({ let expected_response = json!({
"message": "You must specify where `sort` is listed in the rankingRules setting to use the sort parameter at search time.", "message": "You must specify where `sort` is listed in the rankingRules setting to use the sort parameter at search time.",
@ -1070,14 +1070,13 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings_searchable_attributes(json!(["id", "title"])).await; index.update_settings_searchable_attributes(json!(["id", "title"])).await;
index.wait_task(0).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await.succeeded();
index index
.search( .search(
@ -1099,14 +1098,13 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("test"); let index = server.unique_index();
index.update_settings_searchable_attributes(json!(["id", "title"])).await; index.update_settings_searchable_attributes(json!(["id", "title"])).await;
index.wait_task(0).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await.succeeded();
index index
.search( .search(
@ -1145,11 +1143,10 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("tamo"); let index = server.unique_index();
let (task, _) = index.create(None).await; let (task, _) = index.create(None).await;
let task = index.wait_task(task.uid()).await; index.wait_task(task.uid()).await.succeeded();
snapshot!(task, name: "task-succeed");
let (response, code) = let (response, code) =
index.search_post(json!({"page": 0, "hitsPerPage": 2, "distinct": "doggo.truc"})).await; index.search_post(json!({"page": 0, "hitsPerPage": 2, "distinct": "doggo.truc"})).await;
@ -1210,8 +1207,8 @@ 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().await; let server = Server::new_shared().await;
let index = server.index("doggo"); 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.
let (task, _code) = index.create(None).await; let (task, _code) = index.create(None).await;

View File

@ -2,7 +2,7 @@
source: meilisearch/tests/search/distinct.rs source: meilisearch/tests/search/distinct.rs
--- ---
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "tamo", "indexUid": "tamo",
"status": "succeeded", "status": "succeeded",
"type": "settingsUpdate", "type": "settingsUpdate",

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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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().await; let server = Server::new_shared().await;
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");

View File

@ -744,7 +744,7 @@ async fn test_summarized_index_deletion() {
snapshot!(task, snapshot!(task,
@r###" @r###"
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "indexDeletion", "type": "indexDeletion",
@ -774,7 +774,7 @@ async fn test_summarized_index_deletion() {
snapshot!(task, snapshot!(task,
@r###" @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -796,7 +796,7 @@ async fn test_summarized_index_deletion() {
snapshot!(task, snapshot!(task,
@r###" @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "indexDeletion", "type": "indexDeletion",
@ -818,7 +818,7 @@ async fn test_summarized_index_deletion() {
snapshot!(task, snapshot!(task,
@r###" @r###"
{ {
"uid": 3, "uid": "[uid]",
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "indexDeletion", "type": "indexDeletion",

View File

@ -218,7 +218,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -247,7 +247,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 3, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -277,7 +277,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 4, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -306,7 +306,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 5, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -335,7 +335,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 6, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -364,7 +364,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 7, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -405,7 +405,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 10, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -433,7 +433,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 11, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -461,7 +461,7 @@ async fn user_provided_embeddings_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 12, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -497,7 +497,7 @@ async fn user_provided_vectors_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -526,7 +526,7 @@ async fn user_provided_vectors_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 3, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -555,7 +555,7 @@ async fn user_provided_vectors_error() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 4, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",

View File

@ -896,7 +896,7 @@ async fn bad_settings() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
@ -990,7 +990,7 @@ async fn add_vector_and_user_provided() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1086,7 +1086,7 @@ async fn server_returns_bad_request() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
@ -1198,7 +1198,7 @@ async fn server_returns_bad_response() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
@ -1251,7 +1251,7 @@ async fn server_returns_bad_response() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
@ -1306,7 +1306,7 @@ async fn server_returns_bad_response() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
@ -1361,7 +1361,7 @@ async fn server_returns_bad_response() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 3, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
@ -1426,7 +1426,7 @@ async fn server_returns_bad_response() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 4, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
@ -1493,7 +1493,7 @@ async fn server_returns_multiple() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1598,7 +1598,7 @@ async fn server_single_input_returns_in_array() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1703,7 +1703,7 @@ async fn server_raw() {
let task = index.wait_task(value.uid()).await; let task = index.wait_task(value.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
@ -1800,7 +1800,7 @@ async fn server_custom_header() {
let task = server.wait_task(response.uid()).await; let task = server.wait_task(response.uid()).await;
snapshot!(task, @r###" snapshot!(task, @r###"
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",

View File

@ -43,7 +43,7 @@ async fn update_embedder() {
let ret = server.wait_task(response.uid()).await; let ret = server.wait_task(response.uid()).await;
snapshot!(ret, @r###" snapshot!(ret, @r###"
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "settingsUpdate", "type": "settingsUpdate",

View File

@ -2,7 +2,7 @@
source: meilisearch/tests/vector/mod.rs source: meilisearch/tests/vector/mod.rs
--- ---
{ {
"uid": 1, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",

View File

@ -2,7 +2,7 @@
source: meilisearch/tests/vector/mod.rs source: meilisearch/tests/vector/mod.rs
--- ---
{ {
"uid": 2, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",

View File

@ -2,7 +2,7 @@
source: meilisearch/tests/vector/mod.rs source: meilisearch/tests/vector/mod.rs
--- ---
{ {
"uid": 0, "uid": "[uid]",
"indexUid": "doggo", "indexUid": "doggo",
"status": "succeeded", "status": "succeeded",
"type": "settingsUpdate", "type": "settingsUpdate",