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

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

View File

@ -661,7 +661,8 @@ fn search_with_settings_basic() {
"popularity" "popularity"
], ],
"stopWords": null, "stopWords": null,
"synonyms": null "synonyms": null,
"indexNewFields": false,
}); });
common::update_config(&mut server, config); common::update_config(&mut server, config);
@ -766,7 +767,8 @@ fn search_with_settings_stop_words() {
"popularity" "popularity"
], ],
"stopWords": ["the"], "stopWords": ["the"],
"synonyms": null "synonyms": null,
"indexNewFields": false,
}); });
common::update_config(&mut server, config); common::update_config(&mut server, config);
@ -877,7 +879,8 @@ fn search_with_settings_synonyms() {
"Captain America", "Captain America",
"Iron Man" "Iron Man"
] ]
} },
"indexNewFields": false,
}); });
common::update_config(&mut server, config); common::update_config(&mut server, config);
@ -983,7 +986,8 @@ fn search_with_settings_ranking_rules() {
"popularity" "popularity"
], ],
"stopWords": null, "stopWords": null,
"synonyms": null "synonyms": null,
"indexNewFields": false,
}); });
common::update_config(&mut server, config); common::update_config(&mut server, config);
@ -1088,7 +1092,8 @@ fn search_with_settings_attributes_searchable() {
"popularity" "popularity"
], ],
"stopWords": null, "stopWords": null,
"synonyms": null "synonyms": null,
"indexNewFields": false,
}); });
common::update_config(&mut server, config); common::update_config(&mut server, config);
@ -1096,23 +1101,6 @@ fn search_with_settings_attributes_searchable() {
let query = "q=avangers&limit=3"; let query = "q=avangers&limit=3";
let response = json!([ 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, "id": 299536,
"popularity": 65.013, "popularity": 65.013,
@ -1130,6 +1118,23 @@ fn search_with_settings_attributes_searchable() {
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg", "poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
"vote_count": 16056 "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, "id": 100402,
"popularity": 16.418, "popularity": 16.418,
@ -1188,7 +1193,8 @@ fn search_with_settings_attributes_displayed() {
"poster_path" "poster_path"
], ],
"stopWords": null, "stopWords": null,
"synonyms": null "synonyms": null,
"indexNewFields": false,
}); });
common::update_config(&mut server, config); common::update_config(&mut server, config);
@ -1197,11 +1203,11 @@ fn search_with_settings_attributes_displayed() {
let query = "q=avangers&limit=3"; let query = "q=avangers&limit=3";
let response = json!([ let response = json!([
{ {
"id": 24428, "id": 299536,
"title": "The Avengers", "title": "Avengers: Infinity War",
"tagline": "Some assembly required.", "tagline": "An entire universe. Once and for all.",
"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!", "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/cezWGskPY5x7GaglTTRN4Fugfb8.jpg" "poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
}, },
{ {
"id": 299534, "id": 299534,
@ -1211,11 +1217,11 @@ fn search_with_settings_attributes_displayed() {
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg" "poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
}, },
{ {
"id": 299536, "id": 99861,
"title": "Avengers: Infinity War", "title": "Avengers: Age of Ultron",
"tagline": "An entire universe. Once and for all.", "tagline": "A New Age Has Come.",
"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.", "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/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg" "poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg"
} }
]); ]);
@ -1258,7 +1264,8 @@ fn search_with_settings_attributes_searchable_2() {
"poster_path" "poster_path"
], ],
"stopWords": null, "stopWords": null,
"synonyms": null "synonyms": null,
"indexNewFields": false,
}); });
common::update_config(&mut server, config); common::update_config(&mut server, config);
@ -1266,13 +1273,6 @@ fn search_with_settings_attributes_searchable_2() {
let query = "q=avangers&limit=3"; let query = "q=avangers&limit=3";
let response = json!([ 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, "id": 299536,
"title": "Avengers: Infinity War", "title": "Avengers: Infinity War",
@ -1280,6 +1280,13 @@ fn search_with_settings_attributes_searchable_2() {
"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.", "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" "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, "id": 100402,
"title": "Captain America: The Winter Soldier", "title": "Captain America: The Winter Soldier",

View File

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