update tests

This commit is contained in:
qdequele 2020-01-27 18:27:42 +01:00
parent 10b8a0ab00
commit 037724576e
No known key found for this signature in database
GPG Key ID: B3F0A000EBF11745
4 changed files with 76 additions and 65 deletions

View File

@ -101,7 +101,7 @@ pub async fn delete_all(ctx: Request<Data>) -> SResult<Response> {
attributes_displayed: UpdateState::Clear,
stop_words: UpdateState::Clear,
synonyms: UpdateState::Clear,
index_new_fields: UpdateState::Clear,
index_new_fields: UpdateState::Clear,
};
let update_id = index.settings_update(&mut writer, settings)?;

View File

@ -3,9 +3,9 @@ use serde_json::Value;
use std::error::Error;
use std::time::Duration;
use async_std::task::{block_on, sleep};
use async_std::io::prelude::*;
use assert_json_diff::assert_json_eq;
use async_std::io::prelude::*;
use async_std::task::{block_on, sleep};
use http_service::Body;
use http_service_mock::{make_server, TestBackend};
use meilisearch_http::data::Data;
@ -89,7 +89,8 @@ pub fn enrich_server_with_movies_settings(
"popularity",
],
"stopWords": null,
"synonyms": null
"synonyms": null,
"indexNewFields": false,
});
let body = json.to_string().into_bytes();

View File

@ -661,7 +661,8 @@ fn search_with_settings_basic() {
"popularity"
],
"stopWords": null,
"synonyms": null
"synonyms": null,
"indexNewFields": false,
});
common::update_config(&mut server, config);
@ -766,7 +767,8 @@ fn search_with_settings_stop_words() {
"popularity"
],
"stopWords": ["the"],
"synonyms": null
"synonyms": null,
"indexNewFields": false,
});
common::update_config(&mut server, config);
@ -877,7 +879,8 @@ fn search_with_settings_synonyms() {
"Captain America",
"Iron Man"
]
}
},
"indexNewFields": false,
});
common::update_config(&mut server, config);
@ -983,7 +986,8 @@ fn search_with_settings_ranking_rules() {
"popularity"
],
"stopWords": null,
"synonyms": null
"synonyms": null,
"indexNewFields": false,
});
common::update_config(&mut server, config);
@ -1088,7 +1092,8 @@ fn search_with_settings_attributes_searchable() {
"popularity"
],
"stopWords": null,
"synonyms": null
"synonyms": null,
"indexNewFields": false,
});
common::update_config(&mut server, config);
@ -1096,23 +1101,6 @@ fn search_with_settings_attributes_searchable() {
let query = "q=avangers&limit=3";
let response = json!([
{
"id": 299534,
"popularity": 38.659,
"vote_average": 8.3,
"title": "Avengers: Endgame",
"tagline": "Part of the journey is the end.",
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Adventure",
"Science Fiction",
"Action"
],
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg",
"vote_count": 10497
},
{
"id": 299536,
"popularity": 65.013,
@ -1130,6 +1118,23 @@ fn search_with_settings_attributes_searchable() {
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
"vote_count": 16056
},
{
"id": 299534,
"popularity": 38.659,
"vote_average": 8.3,
"title": "Avengers: Endgame",
"tagline": "Part of the journey is the end.",
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Adventure",
"Science Fiction",
"Action"
],
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg",
"vote_count": 10497
},
{
"id": 100402,
"popularity": 16.418,
@ -1188,7 +1193,8 @@ fn search_with_settings_attributes_displayed() {
"poster_path"
],
"stopWords": null,
"synonyms": null
"synonyms": null,
"indexNewFields": false,
});
common::update_config(&mut server, config);
@ -1197,11 +1203,11 @@ fn search_with_settings_attributes_displayed() {
let query = "q=avangers&limit=3";
let response = json!([
{
"id": 24428,
"title": "The Avengers",
"tagline": "Some assembly required.",
"overview": "When an unexpected enemy emerges and threatens global safety and security, Nick Fury, director of the international peacekeeping agency known as S.H.I.E.L.D., finds himself in need of a team to pull the world back from the brink of disaster. Spanning the globe, a daring recruitment effort begins!",
"poster_path": "https://image.tmdb.org/t/p/w500/cezWGskPY5x7GaglTTRN4Fugfb8.jpg"
"id": 299536,
"title": "Avengers: Infinity War",
"tagline": "An entire universe. Once and for all.",
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
},
{
"id": 299534,
@ -1211,11 +1217,11 @@ fn search_with_settings_attributes_displayed() {
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
},
{
"id": 299536,
"title": "Avengers: Infinity War",
"tagline": "An entire universe. Once and for all.",
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
"id": 99861,
"title": "Avengers: Age of Ultron",
"tagline": "A New Age Has Come.",
"overview": "When Tony Stark tries to jumpstart a dormant peacekeeping program, things go awry and Earths Mightiest Heroes are put to the ultimate test as the fate of the planet hangs in the balance. As the villainous Ultron emerges, it is up to The Avengers to stop him from enacting his terrible plans, and soon uneasy alliances and unexpected action pave the way for an epic and unique global adventure.",
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg"
}
]);
@ -1258,7 +1264,8 @@ fn search_with_settings_attributes_searchable_2() {
"poster_path"
],
"stopWords": null,
"synonyms": null
"synonyms": null,
"indexNewFields": false,
});
common::update_config(&mut server, config);
@ -1266,28 +1273,28 @@ fn search_with_settings_attributes_searchable_2() {
let query = "q=avangers&limit=3";
let response = json!([
{
"id": 299534,
"title": "Avengers: Endgame",
"tagline": "Part of the journey is the end.",
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
},
{
"id": 299536,
"title": "Avengers: Infinity War",
"tagline": "An entire universe. Once and for all.",
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
},
{
"id": 100402,
"title": "Captain America: The Winter Soldier",
"tagline": "In heroes we trust.",
"overview": "After the cataclysmic events in New York with The Avengers, Steve Rogers, aka Captain America is living quietly in Washington, D.C. and trying to adjust to the modern world. But when a S.H.I.E.L.D. colleague comes under attack, Steve becomes embroiled in a web of intrigue that threatens to put the world at risk. Joining forces with the Black Widow, Captain America struggles to expose the ever-widening conspiracy while fighting off professional assassins sent to silence him at every turn. When the full scope of the villainous plot is revealed, Captain America and the Black Widow enlist the help of a new ally, the Falcon. However, they soon find themselves up against an unexpected and formidable enemy—the Winter Soldier.",
"poster_path": "https://image.tmdb.org/t/p/w500/5TQ6YDmymBpnF005OyoB7ohZps9.jpg"
}
]);
{
"id": 299536,
"title": "Avengers: Infinity War",
"tagline": "An entire universe. Once and for all.",
"overview": "As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.",
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
},
{
"id": 299534,
"title": "Avengers: Endgame",
"tagline": "Part of the journey is the end.",
"overview": "After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.",
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
},
{
"id": 100402,
"title": "Captain America: The Winter Soldier",
"tagline": "In heroes we trust.",
"overview": "After the cataclysmic events in New York with The Avengers, Steve Rogers, aka Captain America is living quietly in Washington, D.C. and trying to adjust to the modern world. But when a S.H.I.E.L.D. colleague comes under attack, Steve becomes embroiled in a web of intrigue that threatens to put the world at risk. Joining forces with the Black Widow, Captain America struggles to expose the ever-widening conspiracy while fighting off professional assassins sent to silence him at every turn. When the full scope of the villainous plot is revealed, Captain America and the Black Widow enlist the help of a new ally, the Falcon. However, they soon find themselves up against an unexpected and formidable enemy—the Winter Soldier.",
"poster_path": "https://image.tmdb.org/t/p/w500/5TQ6YDmymBpnF005OyoB7ohZps9.jpg"
}
]);
common::search(&mut server, query, response);
}

View File

@ -75,7 +75,8 @@ fn write_all_and_delete() {
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"],
}
},
"indexNewFields": false,
});
let body = json.to_string().into_bytes();
@ -132,7 +133,7 @@ fn write_all_and_delete() {
"attributesDisplayed": null,
"stopWords": null,
"synonyms": null,
"indexNewFields": true,
"indexNewFields": null,
});
assert_json_eq!(json, res_value, ordered: false);
@ -203,7 +204,8 @@ fn write_all_and_update() {
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"],
}
},
"indexNewFields": false,
});
let body = json.to_string().into_bytes();
@ -260,7 +262,8 @@ fn write_all_and_update() {
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine", "xmen"],
}
},
"indexNewFields": false,
});
let body_update = json_update.to_string().into_bytes();
@ -314,7 +317,7 @@ fn write_all_and_update() {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine", "xmen"],
},
"indexNewFields": true
"indexNewFields": false
});
assert_json_eq!(res_expected, res_value, ordered: false);