mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-06 20:25:40 +00:00
Print [uuid]
instead of the Uuid index name for MeilisearchHttpError::Milli errors
This way the tests' assertions/snapshots for unique indices would be stable Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
parent
8c8d98eeaa
commit
34d58f35c8
@ -64,7 +64,7 @@ pub enum MeilisearchHttpError {
|
|||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IndexScheduler(#[from] index_scheduler::Error),
|
IndexScheduler(#[from] index_scheduler::Error),
|
||||||
#[error("{}", match .index_name {
|
#[error("{}", match .index_name {
|
||||||
Some(name) if !name.is_empty() => format!("Index `{}`: {error}", name),
|
Some(name) if !name.is_empty() => format!("Index `{}`: {error}", MeilisearchHttpError::index_name(name)),
|
||||||
_ => format!("{error}")
|
_ => format!("{error}")
|
||||||
})]
|
})]
|
||||||
Milli { error: milli::Error, index_name: Option<String> },
|
Milli { error: milli::Error, index_name: Option<String> },
|
||||||
@ -84,6 +84,14 @@ impl MeilisearchHttpError {
|
|||||||
pub(crate) fn from_milli(error: milli::Error, index_name: Option<String>) -> Self {
|
pub(crate) fn from_milli(error: milli::Error, index_name: Option<String>) -> Self {
|
||||||
Self::Milli { error, index_name }
|
Self::Milli { error, index_name }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn index_name(index_name: &str) -> &str {
|
||||||
|
if let Ok(_) = uuid::Uuid::parse_str(index_name) {
|
||||||
|
"[uuid]"
|
||||||
|
} else {
|
||||||
|
index_name
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ErrorCode for MeilisearchHttpError {
|
impl ErrorCode for MeilisearchHttpError {
|
||||||
|
@ -729,7 +729,7 @@ async fn filter_invalid_attribute_string() {
|
|||||||
|response, code| {
|
|response, code| {
|
||||||
snapshot!(response, @r###"
|
snapshot!(response, @r###"
|
||||||
{
|
{
|
||||||
"message": "Index `test`: Attribute `many` is not filterable. Available filterable attribute patterns are: `title`.\n1:5 many = Glass",
|
"message": "Index `[uuid]`: Attribute `many` is not filterable. Available filterable attribute patterns are: `title`.\n1:5 many = Glass",
|
||||||
"code": "invalid_search_filter",
|
"code": "invalid_search_filter",
|
||||||
"type": "invalid_request",
|
"type": "invalid_request",
|
||||||
"link": "https://docs.meilisearch.com/errors#invalid_search_filter"
|
"link": "https://docs.meilisearch.com/errors#invalid_search_filter"
|
||||||
|
@ -17,11 +17,9 @@ mod restrict_searchable;
|
|||||||
mod search_queue;
|
mod search_queue;
|
||||||
|
|
||||||
use meili_snap::{json_string, snapshot};
|
use meili_snap::{json_string, snapshot};
|
||||||
use meilisearch::Opt;
|
|
||||||
use tempfile::TempDir;
|
|
||||||
|
|
||||||
use crate::common::{
|
use crate::common::{
|
||||||
default_settings, shared_index_with_documents, shared_index_with_nested_documents,
|
shared_index_with_documents, shared_index_with_nested_documents,
|
||||||
shared_index_with_score_documents, Server, Value, DOCUMENTS, FRUITS_DOCUMENTS,
|
shared_index_with_score_documents, Server, Value, DOCUMENTS, FRUITS_DOCUMENTS,
|
||||||
NESTED_DOCUMENTS, SCORE_DOCUMENTS, VECTOR_DOCUMENTS,
|
NESTED_DOCUMENTS, SCORE_DOCUMENTS, VECTOR_DOCUMENTS,
|
||||||
};
|
};
|
||||||
@ -33,11 +31,10 @@ async fn test_settings_documents_indexing_swapping_and_search(
|
|||||||
query: &Value,
|
query: &Value,
|
||||||
test: impl Fn(Value, actix_http::StatusCode) + std::panic::UnwindSafe + Clone,
|
test: impl Fn(Value, actix_http::StatusCode) + std::panic::UnwindSafe + Clone,
|
||||||
) {
|
) {
|
||||||
let temp = TempDir::new().unwrap();
|
let server = Server::new_shared();
|
||||||
let server = Server::new_with_options(Opt { ..default_settings(temp.path()) }).await.unwrap();
|
|
||||||
|
|
||||||
eprintln!("Documents -> Settings -> test");
|
eprintln!("Documents -> Settings -> test");
|
||||||
let index = server.index("test");
|
let index = server.unique_index();
|
||||||
|
|
||||||
let (task, code) = index.add_documents(documents.clone(), None).await;
|
let (task, code) = index.add_documents(documents.clone(), None).await;
|
||||||
assert_eq!(code, 202, "{task}");
|
assert_eq!(code, 202, "{task}");
|
||||||
@ -48,12 +45,9 @@ async fn test_settings_documents_indexing_swapping_and_search(
|
|||||||
index.wait_task(task.uid()).await.succeeded();
|
index.wait_task(task.uid()).await.succeeded();
|
||||||
|
|
||||||
index.search(query.clone(), test.clone()).await;
|
index.search(query.clone(), test.clone()).await;
|
||||||
let (task, code) = server.delete_index("test").await;
|
|
||||||
assert_eq!(code, 202, "{task}");
|
|
||||||
server.wait_task(task.uid()).await.succeeded();
|
|
||||||
|
|
||||||
eprintln!("Settings -> Documents -> test");
|
eprintln!("Settings -> Documents -> test");
|
||||||
let index = server.index("test");
|
let index = server.unique_index();
|
||||||
|
|
||||||
let (task, code) = index.update_settings(settings.clone()).await;
|
let (task, code) = index.update_settings(settings.clone()).await;
|
||||||
assert_eq!(code, 202, "{task}");
|
assert_eq!(code, 202, "{task}");
|
||||||
@ -64,9 +58,6 @@ async fn test_settings_documents_indexing_swapping_and_search(
|
|||||||
index.wait_task(task.uid()).await.succeeded();
|
index.wait_task(task.uid()).await.succeeded();
|
||||||
|
|
||||||
index.search(query.clone(), test.clone()).await;
|
index.search(query.clone(), test.clone()).await;
|
||||||
let (task, code) = server.delete_index("test").await;
|
|
||||||
assert_eq!(code, 202, "{task}");
|
|
||||||
server.wait_task(task.uid()).await.succeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user