mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-18 10:28:10 +00:00
Introduce Index::unique_index_with_prefix(&str)
It could be used when we want to see the index name in the assertions, e.g. `movies-[uuid]` Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
parent
34d8a54c4b
commit
1824fbd1b5
@ -43,20 +43,10 @@ pub fn default_snapshot_settings_for_test<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uuid_in_index_uid_redaction(content: Content, _content_path: ContentPath) -> Content {
|
|
||||||
match &content {
|
|
||||||
Content::String(s) => match uuid::Uuid::parse_str(s) {
|
|
||||||
Ok(_) => Content::String("[uuid]".to_owned()),
|
|
||||||
Err(_) => content,
|
|
||||||
},
|
|
||||||
_ => content,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.add_dynamic_redaction(".message", uuid_in_message_redaction);
|
settings.add_dynamic_redaction(".message", uuid_in_message_redaction);
|
||||||
settings.add_dynamic_redaction(".error.message", uuid_in_message_redaction);
|
settings.add_dynamic_redaction(".**.message", uuid_in_message_redaction);
|
||||||
settings.add_dynamic_redaction(".indexUid", uuid_in_index_uid_redaction);
|
settings.add_dynamic_redaction(".indexUid", uuid_in_message_redaction);
|
||||||
settings.add_dynamic_redaction(".**.indexUid", uuid_in_index_uid_redaction);
|
settings.add_dynamic_redaction(".**.indexUid", uuid_in_message_redaction);
|
||||||
|
|
||||||
let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name);
|
let test_name = test_name.strip_suffix("::{{closure}}").unwrap_or(test_name);
|
||||||
let test_name = test_name.rsplit("::").next().unwrap().to_owned();
|
let test_name = test_name.rsplit("::").next().unwrap().to_owned();
|
||||||
|
@ -347,6 +347,16 @@ impl<State> Server<State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unique_index_with_prefix(&self, prefix: &str) -> Index<'_> {
|
||||||
|
let uuid = Uuid::new_v4();
|
||||||
|
Index {
|
||||||
|
uid: format!("{prefix}-{}", uuid.to_string()),
|
||||||
|
service: &self.service,
|
||||||
|
encoder: Encoder::Plain,
|
||||||
|
marker: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn unique_index_with_encoder(&self, encoder: Encoder) -> Index<'_> {
|
pub fn unique_index_with_encoder(&self, encoder: Encoder) -> Index<'_> {
|
||||||
let uuid = Uuid::new_v4();
|
let uuid = Uuid::new_v4();
|
||||||
Index { uid: uuid.to_string(), service: &self.service, encoder, marker: PhantomData }
|
Index { uid: uuid.to_string(), service: &self.service, encoder, marker: PhantomData }
|
||||||
|
@ -1628,7 +1628,7 @@ async fn federation_sort_same_indexes_different_criterion_opposite_direction() {
|
|||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
||||||
let server = Server::new_shared();
|
let server = Server::new_shared();
|
||||||
let movies_index = server.unique_index();
|
let movies_index = server.unique_index_with_prefix("movies");
|
||||||
|
|
||||||
let documents = DOCUMENTS.clone();
|
let documents = DOCUMENTS.clone();
|
||||||
let (value, _) = movies_index.add_documents(documents, None).await;
|
let (value, _) = movies_index.add_documents(documents, None).await;
|
||||||
@ -1649,7 +1649,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
.await;
|
.await;
|
||||||
movies_index.wait_task(value.uid()).await.succeeded();
|
movies_index.wait_task(value.uid()).await.succeeded();
|
||||||
|
|
||||||
let batman_index = server.unique_index();
|
let batman_index = server.unique_index_with_prefix("batman");
|
||||||
|
|
||||||
let documents = SCORE_DOCUMENTS.clone();
|
let documents = SCORE_DOCUMENTS.clone();
|
||||||
let (value, _) = batman_index.add_documents(documents, None).await;
|
let (value, _) = batman_index.add_documents(documents, None).await;
|
||||||
@ -1678,14 +1678,14 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
]}))
|
]}))
|
||||||
.await;
|
.await;
|
||||||
snapshot!(code, @"200 OK");
|
snapshot!(code, @"200 OK");
|
||||||
insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]", ".**.indexUid" => "[uuid]" }, @r###"
|
snapshot!(json_string!(response, { ".processingTimeMs" => "[time]" }), @r###"
|
||||||
{
|
{
|
||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"title": "Badman",
|
"title": "Badman",
|
||||||
"id": "E",
|
"id": "E",
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "batman-[uuid]",
|
||||||
"queriesPosition": 1,
|
"queriesPosition": 1,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1695,7 +1695,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"title": "Batman",
|
"title": "Batman",
|
||||||
"id": "D",
|
"id": "D",
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "batman-[uuid]",
|
||||||
"queriesPosition": 1,
|
"queriesPosition": 1,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1705,7 +1705,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"title": "Batman Returns",
|
"title": "Batman Returns",
|
||||||
"id": "C",
|
"id": "C",
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "batman-[uuid]",
|
||||||
"queriesPosition": 1,
|
"queriesPosition": 1,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1715,7 +1715,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"title": "Batman the dark knight returns: Part 1",
|
"title": "Batman the dark knight returns: Part 1",
|
||||||
"id": "A",
|
"id": "A",
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "batman-[uuid]",
|
||||||
"queriesPosition": 1,
|
"queriesPosition": 1,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1725,7 +1725,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"title": "Batman the dark knight returns: Part 2",
|
"title": "Batman the dark knight returns: Part 2",
|
||||||
"id": "B",
|
"id": "B",
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "batman-[uuid]",
|
||||||
"queriesPosition": 1,
|
"queriesPosition": 1,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1739,7 +1739,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"blue"
|
"blue"
|
||||||
],
|
],
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "movies-[uuid]",
|
||||||
"queriesPosition": 0,
|
"queriesPosition": 0,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1753,7 +1753,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"red"
|
"red"
|
||||||
],
|
],
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "movies-[uuid]",
|
||||||
"queriesPosition": 0,
|
"queriesPosition": 0,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1767,7 +1767,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"red"
|
"red"
|
||||||
],
|
],
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "movies-[uuid]",
|
||||||
"queriesPosition": 0,
|
"queriesPosition": 0,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1781,7 +1781,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"red"
|
"red"
|
||||||
],
|
],
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "movies-[uuid]",
|
||||||
"queriesPosition": 0,
|
"queriesPosition": 0,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
@ -1795,7 +1795,7 @@ async fn federation_sort_different_indexes_same_criterion_same_direction() {
|
|||||||
"blue"
|
"blue"
|
||||||
],
|
],
|
||||||
"_federation": {
|
"_federation": {
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "movies-[uuid]",
|
||||||
"queriesPosition": 0,
|
"queriesPosition": 0,
|
||||||
"weightedRankingScore": 1.0
|
"weightedRankingScore": 1.0
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user