Merge pull request #737 from balajisivaraman/wip_655

Improve test suite performance using Test Dataset
This commit is contained in:
Clément Renault 2020-07-02 13:51:38 +02:00 committed by GitHub
commit a626e5e935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1293 additions and 101552 deletions

File diff suppressed because it is too large Load Diff

View File

@ -476,59 +476,4 @@ impl Server {
pub async fn get_sys_info_pretty(&mut self) -> (Value, StatusCode) {
self.get_request("/sys-info/pretty").await
}
// Populate routes
pub async fn populate_movies(&mut self) {
let body = json!({
"uid": "movies",
"primaryKey": "id",
});
self.create_index(body).await;
let body = json!({
"rankingRules": [
"typo",
"words",
"proximity",
"attribute",
"wordsPosition",
"desc(popularity)",
"exactness",
"desc(vote_average)",
],
"searchableAttributes": [
"title",
"tagline",
"overview",
"cast",
"director",
"producer",
"production_companies",
"genres",
],
"displayedAttributes": [
"title",
"director",
"producer",
"tagline",
"genres",
"id",
"overview",
"vote_count",
"vote_average",
"poster_path",
"popularity",
],
"acceptNewFields": false,
});
self.update_all_settings(body).await;
let dataset = include_bytes!("assets/movies.json");
let body: Value = serde_json::from_slice(dataset).unwrap();
self.add_or_replace_multiple_documents(body).await;
}
}

View File

@ -2,30 +2,33 @@ mod common;
#[actix_rt::test]
async fn delete() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let (_response, status_code) = server.get_document(419704).await;
let (_response, status_code) = server.get_document(50).await;
assert_eq!(status_code, 200);
server.delete_document(419704).await;
server.delete_document(50).await;
let (_response, status_code) = server.get_document(419704).await;
let (_response, status_code) = server.get_document(50).await;
assert_eq!(status_code, 404);
}
// Resolve the issue https://github.com/meilisearch/MeiliSearch/issues/493
#[actix_rt::test]
async fn delete_batch() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let (_response, status_code) = server.get_document(419704).await;
assert_eq!(status_code, 200);
let doc_ids = vec!(50, 55, 60);
for doc_id in &doc_ids {
let (_response, status_code) = server.get_document(doc_id).await;
assert_eq!(status_code, 200);
}
let body = serde_json::json!([419704, 512200, 181812]);
let body = serde_json::json!(&doc_ids);
server.delete_multiple_documents(body).await;
let (_response, status_code) = server.get_document(419704).await;
assert_eq!(status_code, 404);
for doc_id in &doc_ids {
let (_response, status_code) = server.get_document(doc_id).await;
assert_eq!(status_code, 404);
}
}

View File

@ -666,10 +666,10 @@ async fn check_add_documents_without_primary_key() {
#[actix_rt::test]
async fn check_first_update_should_bring_up_processed_status_after_first_docs_addition() {
let mut server = common::Server::with_uid("movies");
let mut server = common::Server::with_uid("test");
let body = json!({
"uid": "movies",
"uid": "test",
});
// 1. Create Index
@ -677,7 +677,7 @@ async fn check_first_update_should_bring_up_processed_status_after_first_docs_ad
assert_eq!(status_code, 201);
assert_eq!(response["primaryKey"], json!(null));
let dataset = include_bytes!("assets/movies.json");
let dataset = include_bytes!("assets/test_set.json");
let body: Value = serde_json::from_slice(dataset).unwrap();

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,7 @@ mod common;
#[actix_rt::test]
async fn search_with_settings_basic() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let config = json!({
"rankingRules": [
@ -16,33 +15,29 @@ async fn search_with_settings_basic() {
"proximity",
"attribute",
"wordsPosition",
"desc(popularity)",
"desc(age)",
"exactness",
"desc(vote_average)"
"desc(balance)"
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"tagline",
"overview",
"cast",
"director",
"producer",
"production_companies",
"genres"
"name",
"age",
"color",
"gender",
"email",
"address",
"about"
],
"displayedAttributes": [
"title",
"director",
"producer",
"tagline",
"genres",
"id",
"overview",
"vote_count",
"vote_average",
"poster_path",
"popularity"
"name",
"age",
"gender",
"color",
"email",
"phone",
"address",
"balance"
],
"stopWords": null,
"synonyms": null,
@ -51,58 +46,38 @@ async fn search_with_settings_basic() {
server.update_all_settings(config).await;
let query = "q=the%20avangers&limit=3";
let query = "q=ea%20exercitation&limit=3";
let expect = json!([
{
"id": 24428,
"popularity": 44.506,
"vote_average": 7.7,
"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!",
"director": "Joss Whedon",
"producer": "Kevin Feige",
"genres": [
"Science Fiction",
"Action",
"Adventure"
],
"poster_path": "https://image.tmdb.org/t/p/w500/cezWGskPY5x7GaglTTRN4Fugfb8.jpg",
"vote_count": 21079
"balance": "$2,467.47",
"age": 34,
"color": "blue",
"name": "Patricia Goff",
"gender": "female",
"email": "patriciagoff@chorizon.com",
"phone": "+1 (864) 463-2277",
"address": "866 Hornell Loop, Cresaptown, Ohio, 1700"
},
{
"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
"balance": "$3,344.40",
"age": 35,
"color": "blue",
"name": "Adeline Flynn",
"gender": "female",
"email": "adelineflynn@chorizon.com",
"phone": "+1 (994) 600-2840",
"address": "428 Paerdegat Avenue, Hollymead, Pennsylvania, 948"
},
{
"id": 299536,
"popularity": 65.013,
"vote_average": 8.3,
"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.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Adventure",
"Action",
"Science Fiction"
],
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
"vote_count": 16056
"balance": "$3,394.96",
"age": 25,
"color": "blue",
"name": "Aida Kirby",
"gender": "female",
"email": "aidakirby@chorizon.com",
"phone": "+1 (942) 532-2325",
"address": "797 Engert Avenue, Wilsonia, Idaho, 6532"
}
]);
@ -112,8 +87,7 @@ async fn search_with_settings_basic() {
#[actix_rt::test]
async fn search_with_settings_stop_words() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let config = json!({
"rankingRules": [
@ -122,93 +96,68 @@ async fn search_with_settings_stop_words() {
"proximity",
"attribute",
"wordsPosition",
"desc(popularity)",
"desc(age)",
"exactness",
"desc(vote_average)"
"desc(balance)"
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"tagline",
"overview",
"cast",
"director",
"producer",
"production_companies",
"genres"
"name",
"age",
"color",
"gender",
"email",
"address",
"about"
],
"displayedAttributes": [
"title",
"director",
"producer",
"tagline",
"genres",
"id",
"overview",
"vote_count",
"vote_average",
"poster_path",
"popularity"
"name",
"age",
"gender",
"color",
"email",
"phone",
"address",
"balance"
],
"stopWords": ["the"],
"stopWords": ["ea"],
"synonyms": null,
"acceptNewFields": false,
});
server.update_all_settings(config).await;
let query = "q=the%20avangers&limit=3";
let query = "q=ea%20exercitation&limit=3";
let expect = json!([
{
"id": 299536,
"popularity": 65.013,
"vote_average": 8.3,
"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.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Adventure",
"Action",
"Science Fiction"
],
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
"vote_count": 16056
"balance": "$1,921.58",
"age": 31,
"color": "green",
"name": "Harper Carson",
"gender": "male",
"email": "harpercarson@chorizon.com",
"phone": "+1 (912) 430-3243",
"address": "883 Dennett Place, Knowlton, New Mexico, 9219"
},
{
"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
"balance": "$1,706.13",
"age": 27,
"color": "green",
"name": "Cherry Orr",
"gender": "female",
"email": "cherryorr@chorizon.com",
"phone": "+1 (995) 479-3174",
"address": "442 Beverly Road, Ventress, New Mexico, 3361"
},
{
"id": 99861,
"popularity": 33.938,
"vote_average": 7.3,
"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.",
"director": "Joss Whedon",
"producer": "Kevin Feige",
"genres": [
"Action",
"Adventure",
"Science Fiction"
],
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg",
"vote_count": 14661
"balance": "$1,476.39",
"age": 28,
"color": "brown",
"name": "Maureen Dale",
"gender": "female",
"email": "maureendale@chorizon.com",
"phone": "+1 (984) 538-3684",
"address": "817 Newton Street, Bannock, Wyoming, 1468"
}
]);
@ -218,8 +167,7 @@ async fn search_with_settings_stop_words() {
#[actix_rt::test]
async fn search_with_settings_synonyms() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let config = json!({
"rankingRules": [
@ -228,98 +176,72 @@ async fn search_with_settings_synonyms() {
"proximity",
"attribute",
"wordsPosition",
"desc(popularity)",
"desc(age)",
"exactness",
"desc(vote_average)"
"desc(balance)"
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"tagline",
"overview",
"cast",
"director",
"producer",
"production_companies",
"genres"
"name",
"age",
"color",
"gender",
"email",
"address",
"about"
],
"displayedAttributes": [
"title",
"director",
"producer",
"tagline",
"genres",
"id",
"overview",
"vote_count",
"vote_average",
"poster_path",
"popularity"
"name",
"age",
"gender",
"color",
"email",
"phone",
"address",
"balance"
],
"stopWords": null,
"synonyms": {
"avangers": [
"Captain America",
"Iron Man"
]
"application": [
"exercitation"
]
},
"acceptNewFields": false,
});
server.update_all_settings(config).await;
let query = "q=avangers&limit=3";
let query = "q=application&limit=3";
let expect = json!([
{
"id": 299536,
"popularity": 65.013,
"vote_average": 8.3,
"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.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Adventure",
"Action",
"Science Fiction"
],
"vote_count": 16056,
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg"
"balance": "$1,921.58",
"age": 31,
"color": "green",
"name": "Harper Carson",
"gender": "male",
"email": "harpercarson@chorizon.com",
"phone": "+1 (912) 430-3243",
"address": "883 Dennett Place, Knowlton, New Mexico, 9219"
},
{
"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"
],
"vote_count": 10497,
"poster_path": "https://image.tmdb.org/t/p/w500/or06FN3Dka5tukK1e9sl16pB3iy.jpg"
"balance": "$1,706.13",
"age": 27,
"color": "green",
"name": "Cherry Orr",
"gender": "female",
"email": "cherryorr@chorizon.com",
"phone": "+1 (995) 479-3174",
"address": "442 Beverly Road, Ventress, New Mexico, 3361"
},
{
"id": 99861,
"popularity": 33.938,
"vote_average": 7.3,
"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.",
"director": "Joss Whedon",
"producer": "Kevin Feige",
"genres": [
"Action",
"Adventure",
"Science Fiction"
],
"vote_count": 14661,
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg"
"balance": "$1,476.39",
"age": 28,
"color": "brown",
"name": "Maureen Dale",
"gender": "female",
"email": "maureendale@chorizon.com",
"phone": "+1 (984) 538-3684",
"address": "817 Newton Street, Bannock, Wyoming, 1468"
}
]);
@ -329,8 +251,7 @@ async fn search_with_settings_synonyms() {
#[actix_rt::test]
async fn search_with_settings_ranking_rules() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let config = json!({
"rankingRules": [
@ -339,33 +260,29 @@ async fn search_with_settings_ranking_rules() {
"proximity",
"attribute",
"wordsPosition",
"asc(vote_average)",
"desc(age)",
"exactness",
"desc(popularity)"
"desc(balance)"
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"tagline",
"overview",
"cast",
"director",
"producer",
"production_companies",
"genres"
"name",
"age",
"color",
"gender",
"email",
"address",
"about"
],
"displayedAttributes": [
"title",
"director",
"producer",
"tagline",
"genres",
"id",
"overview",
"vote_count",
"vote_average",
"poster_path",
"popularity"
"name",
"age",
"gender",
"color",
"email",
"phone",
"address",
"balance"
],
"stopWords": null,
"synonyms": null,
@ -374,69 +291,48 @@ async fn search_with_settings_ranking_rules() {
server.update_all_settings(config).await;
let query = "q=avangers&limit=3";
let query = "q=exarcitation&limit=3";
let expect = json!([
{
"id": 99861,
"popularity": 33.938,
"vote_average": 7.3,
"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.",
"director": "Joss Whedon",
"producer": "Kevin Feige",
"genres": [
"Action",
"Adventure",
"Science Fiction"
],
"poster_path": "https://image.tmdb.org/t/p/w500/t90Y3G8UGQp0f0DrP60wRu9gfrH.jpg",
"vote_count": 14661
"balance": "$1,921.58",
"age": 31,
"color": "green",
"name": "Harper Carson",
"gender": "male",
"email": "harpercarson@chorizon.com",
"phone": "+1 (912) 430-3243",
"address": "883 Dennett Place, Knowlton, New Mexico, 9219"
},
{
"id": 299536,
"popularity": 65.013,
"vote_average": 8.3,
"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.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Adventure",
"Action",
"Science Fiction"
],
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
"vote_count": 16056
"balance": "$1,706.13",
"age": 27,
"color": "green",
"name": "Cherry Orr",
"gender": "female",
"email": "cherryorr@chorizon.com",
"phone": "+1 (995) 479-3174",
"address": "442 Beverly Road, Ventress, New Mexico, 3361"
},
{
"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
"balance": "$1,476.39",
"age": 28,
"color": "brown",
"name": "Maureen Dale",
"gender": "female",
"email": "maureendale@chorizon.com",
"phone": "+1 (984) 538-3684",
"address": "817 Newton Street, Bannock, Wyoming, 1468"
}
]);
let (response, _status_code) = server.search_get(query).await;
println!("{}", response["hits"].clone());
assert_json_eq!(expect, response["hits"].clone(), ordered: false);
}
#[actix_rt::test]
async fn search_with_settings_searchable_attributes() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let config = json!({
"rankingRules": [
@ -445,92 +341,60 @@ async fn search_with_settings_searchable_attributes() {
"proximity",
"attribute",
"wordsPosition",
"desc(popularity)",
"desc(age)",
"exactness",
"desc(vote_average)"
"desc(balance)"
],
"distinctAttribute": null,
"searchableAttributes": [
"tagline",
"overview",
"cast",
"director",
"producer",
"production_companies",
"genres"
"age",
"color",
"gender",
"address",
"about"
],
"displayedAttributes": [
"title",
"director",
"producer",
"tagline",
"genres",
"id",
"overview",
"vote_count",
"vote_average",
"poster_path",
"popularity"
"name",
"age",
"gender",
"color",
"email",
"phone",
"address",
"balance"
],
"stopWords": null,
"synonyms": null,
"synonyms": {
"exarcitation": [
"exercitation"
]
},
"acceptNewFields": false,
});
server.update_all_settings(config).await;
let query = "q=avangers&limit=3";
let query = "q=Carol&limit=3";
let expect = json!([
{
"id": 299536,
"popularity": 65.013,
"vote_average": 8.3,
"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.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Adventure",
"Action",
"Science Fiction"
],
"poster_path": "https://image.tmdb.org/t/p/w500/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
"vote_count": 16056
"balance": "$1,440.09",
"age": 40,
"color": "blue",
"name": "Levy Whitley",
"gender": "male",
"email": "levywhitley@chorizon.com",
"phone": "+1 (911) 458-2411",
"address": "187 Thomas Street, Hachita, North Carolina, 2989"
},
{
"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,
"vote_average": 7.7,
"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.",
"director": "Anthony Russo",
"producer": "Kevin Feige",
"genres": [
"Action",
"Adventure",
"Science Fiction"
],
"poster_path": "https://image.tmdb.org/t/p/w500/5TQ6YDmymBpnF005OyoB7ohZps9.jpg",
"vote_count": 11972
"balance": "$1,977.66",
"age": 36,
"color": "brown",
"name": "Combs Stanley",
"gender": "male",
"email": "combsstanley@chorizon.com",
"phone": "+1 (827) 419-2053",
"address": "153 Beverley Road, Siglerville, South Carolina, 3666"
}
]);
@ -540,8 +404,7 @@ async fn search_with_settings_searchable_attributes() {
#[actix_rt::test]
async fn search_with_settings_displayed_attributes() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let config = json!({
"rankingRules": [
@ -550,27 +413,25 @@ async fn search_with_settings_displayed_attributes() {
"proximity",
"attribute",
"wordsPosition",
"desc(popularity)",
"desc(age)",
"exactness",
"desc(vote_average)"
"desc(balance)"
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"tagline",
"overview",
"cast",
"director",
"producer",
"production_companies",
"genres"
"age",
"color",
"gender",
"address",
"about"
],
"displayedAttributes": [
"title",
"tagline",
"id",
"overview",
"poster_path"
"name",
"age",
"gender",
"color",
"email",
"phone"
],
"stopWords": null,
"synonyms": null,
@ -579,28 +440,31 @@ async fn search_with_settings_displayed_attributes() {
server.update_all_settings(config).await;
let query = "q=avangers&limit=3";
let query = "q=exercitation&limit=3";
let expect = json!([
{
"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"
"age": 31,
"color": "green",
"name": "Harper Carson",
"gender": "male",
"email": "harpercarson@chorizon.com",
"phone": "+1 (912) 430-3243"
},
{
"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"
"age": 27,
"color": "green",
"name": "Cherry Orr",
"gender": "female",
"email": "cherryorr@chorizon.com",
"phone": "+1 (995) 479-3174"
},
{
"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"
"age": 28,
"color": "brown",
"name": "Maureen Dale",
"gender": "female",
"email": "maureendale@chorizon.com",
"phone": "+1 (984) 538-3684"
}
]);
@ -610,8 +474,7 @@ async fn search_with_settings_displayed_attributes() {
#[actix_rt::test]
async fn search_with_settings_searchable_attributes_2() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
let config = json!({
"rankingRules": [
@ -620,27 +483,22 @@ async fn search_with_settings_searchable_attributes_2() {
"proximity",
"attribute",
"wordsPosition",
"desc(popularity)",
"desc(age)",
"exactness",
"desc(vote_average)"
"desc(balance)"
],
"distinctAttribute": null,
"searchableAttributes": [
"tagline",
"overview",
"title",
"cast",
"director",
"producer",
"production_companies",
"genres"
"age",
"color",
"gender",
"address",
"about"
],
"displayedAttributes": [
"title",
"tagline",
"id",
"overview",
"poster_path"
"name",
"age",
"gender"
],
"stopWords": null,
"synonyms": null,
@ -649,28 +507,22 @@ async fn search_with_settings_searchable_attributes_2() {
server.update_all_settings(config).await;
let query = "q=avangers&limit=3";
let query = "q=exercitation&limit=3";
let expect = json!([
{
"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"
"age": 31,
"name": "Harper Carson",
"gender": "male"
},
{
"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"
"age": 27,
"name": "Cherry Orr",
"gender": "female"
},
{
"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"
"age": 28,
"name": "Maureen Dale",
"gender": "female"
}
]);

View File

@ -1,13 +1,11 @@
use assert_json_diff::assert_json_eq;
use serde_json::json;
use std::convert::Into;
mod common;
#[actix_rt::test]
async fn write_all_and_delete() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
// 2 - Send the settings
let body = json!({
@ -18,40 +16,41 @@ async fn write_all_and_delete() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(rank)",
"desc(registered)",
"desc(age)",
],
"distinctAttribute": "movie_id",
"distinctAttribute": "id",
"searchableAttributes": [
"id",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank",
"name",
"color",
"gender",
"email",
"phone",
"address",
"registered",
"about"
],
"displayedAttributes": [
"title",
"description",
"poster",
"release_date",
"rank",
"name",
"gender",
"email",
"registered",
"age",
],
"stopWords": [
"the",
"a",
"an",
"ad",
"in",
"ut",
],
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"],
"road": ["street", "avenue"],
"street": ["avenue"],
},
"attributesForFaceting": ["title"],
"attributesForFaceting": ["name"],
"acceptNewFields": false,
});
server.update_all_settings(body.clone()).await;
// 3 - Get all settings and compare to the previous one
@ -79,44 +78,40 @@ async fn write_all_and_delete() {
],
"distinctAttribute": null,
"searchableAttributes": [
"poster_path",
"director",
"address",
"id",
"production_companies",
"producer",
"poster",
"movie_id",
"vote_count",
"cast",
"release_date",
"vote_average",
"rank",
"genres",
"overview",
"description",
"tagline",
"popularity",
"title"
"longitude",
"phone",
"age",
"gender",
"latitude",
"email",
"about",
"registered",
"picture",
"isActive",
"tags",
"name",
"color",
"balance"
],
"displayedAttributes": [
"poster_path",
"poster",
"vote_count",
"address",
"id",
"movie_id",
"title",
"rank",
"tagline",
"cast",
"producer",
"production_companies",
"description",
"director",
"genres",
"release_date",
"overview",
"vote_average",
"popularity"
"longitude",
"phone",
"age",
"gender",
"latitude",
"email",
"about",
"registered",
"picture",
"isActive",
"tags",
"name",
"color",
"balance"
],
"stopWords": [],
"synonyms": {},
@ -129,8 +124,7 @@ async fn write_all_and_delete() {
#[actix_rt::test]
async fn write_all_and_update() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
// 2 - Send the settings
@ -142,36 +136,38 @@ async fn write_all_and_update() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(rank)",
"desc(registered)",
"desc(age)",
],
"distinctAttribute": "movie_id",
"distinctAttribute": "id",
"searchableAttributes": [
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank",
"id",
"name",
"color",
"gender",
"email",
"phone",
"address",
"registered",
"about"
],
"displayedAttributes": [
"title",
"description",
"poster",
"release_date",
"rank",
"name",
"gender",
"email",
"registered",
"age",
],
"stopWords": [
"the",
"a",
"an",
"ad",
"in",
"ut",
],
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"],
"road": ["street", "avenue"],
"street": ["avenue"],
},
"attributesForFaceting": ["title"],
"attributesForFaceting": ["name"],
"acceptNewFields": false,
});
@ -193,25 +189,25 @@ async fn write_all_and_update() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(age)",
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"description",
"uid",
"name",
"color",
"age",
],
"displayedAttributes": [
"title",
"description",
"release_date",
"rank",
"poster",
"name",
"color",
"age",
"registered",
"picture",
],
"stopWords": [],
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine", "xmen"],
"road": ["street", "avenue"],
"street": ["avenue"],
},
"attributesForFaceting": ["title"],
"acceptNewFields": false,
@ -231,28 +227,28 @@ async fn write_all_and_update() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(age)",
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"description",
"uid",
"name",
"color",
"age",
],
"displayedAttributes": [
"title",
"description",
"release_date",
"rank",
"poster",
"name",
"color",
"age",
"registered",
"picture",
],
"stopWords": [],
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine", "xmen"],
"road": ["street", "avenue"],
"street": ["avenue"],
},
"attributesForFaceting": ["title"],
"acceptNewFields": false
"acceptNewFields": false,
});
assert_json_eq!(expected, response, ordered: false);
@ -260,9 +256,9 @@ async fn write_all_and_update() {
#[actix_rt::test]
async fn test_default_settings() {
let mut server = common::Server::with_uid("movies");
let mut server = common::Server::with_uid("test");
let body = json!({
"uid": "movies",
"uid": "test",
});
server.create_index(body).await;
@ -293,9 +289,9 @@ async fn test_default_settings() {
#[actix_rt::test]
async fn test_default_settings_2() {
let mut server = common::Server::with_uid("movies");
let mut server = common::Server::with_uid("test");
let body = json!({
"uid": "movies",
"uid": "test",
"primaryKey": "id",
});
server.create_index(body).await;
@ -332,9 +328,9 @@ async fn test_default_settings_2() {
// Test issue https://github.com/meilisearch/MeiliSearch/issues/516
#[actix_rt::test]
async fn write_setting_and_update_partial() {
let mut server = common::Server::with_uid("movies");
let mut server = common::Server::with_uid("test");
let body = json!({
"uid": "movies",
"uid": "test",
});
server.create_index(body).await;
@ -342,20 +338,21 @@ async fn write_setting_and_update_partial() {
let body = json!({
"searchableAttributes": [
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank",
"id",
"name",
"color",
"gender",
"email",
"phone",
"address",
"about"
],
"displayedAttributes": [
"title",
"description",
"poster",
"release_date",
"rank",
"name",
"gender",
"email",
"registered",
"age",
]
});
@ -371,18 +368,18 @@ async fn write_setting_and_update_partial() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(rank)",
"desc(age)",
"desc(registered)",
],
"distinctAttribute": "movie_id",
"distinctAttribute": "id",
"stopWords": [
"the",
"a",
"an",
"ad",
"in",
"ut",
],
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"],
"road": ["street", "avenue"],
"street": ["avenue"],
},
"acceptNewFields": false,
});
@ -399,34 +396,35 @@ async fn write_setting_and_update_partial() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(rank)",
"desc(age)",
"desc(registered)",
],
"distinctAttribute": "movie_id",
"distinctAttribute": "id",
"searchableAttributes": [
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank",
"id",
"name",
"color",
"gender",
"email",
"phone",
"address",
"about"
],
"displayedAttributes": [
"title",
"description",
"poster",
"release_date",
"rank",
"name",
"gender",
"email",
"registered",
"age",
],
"stopWords": [
"the",
"a",
"an",
"ad",
"in",
"ut",
],
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"],
"road": ["street", "avenue"],
"street": ["avenue"],
},
"attributesForFaceting": [],
"acceptNewFields": false,

View File

@ -5,8 +5,7 @@ mod common;
#[actix_rt::test]
async fn write_all_and_delete() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
// 2 - Send the settings
@ -17,8 +16,8 @@ async fn write_all_and_delete() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(rank)",
"desc(registered)",
"desc(age)",
]);
server.update_ranking_rules(body.clone()).await;
@ -51,8 +50,7 @@ async fn write_all_and_delete() {
#[actix_rt::test]
async fn write_all_and_update() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
// 2 - Send the settings
@ -63,8 +61,8 @@ async fn write_all_and_update() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(rank)",
"desc(registered)",
"desc(age)",
]);
server.update_ranking_rules(body.clone()).await;
@ -84,7 +82,7 @@ async fn write_all_and_update() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(registered)",
]);
server.update_ranking_rules(body).await;
@ -100,7 +98,7 @@ async fn write_all_and_update() {
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(registered)",
]);
assert_json_eq!(expected, response, ordered: false);
@ -108,9 +106,9 @@ async fn write_all_and_update() {
#[actix_rt::test]
async fn send_undefined_rule() {
let mut server = common::Server::with_uid("movies");
let mut server = common::Server::with_uid("test");
let body = json!({
"uid": "movies",
"uid": "test",
"primaryKey": "id",
});
server.create_index(body).await;
@ -123,9 +121,9 @@ async fn send_undefined_rule() {
#[actix_rt::test]
async fn send_malformed_custom_rule() {
let mut server = common::Server::with_uid("movies");
let mut server = common::Server::with_uid("test");
let body = json!({
"uid": "movies",
"uid": "test",
"primaryKey": "id",
});
server.create_index(body).await;
@ -139,16 +137,16 @@ async fn send_malformed_custom_rule() {
// Test issue https://github.com/meilisearch/MeiliSearch/issues/521
#[actix_rt::test]
async fn write_custom_ranking_and_index_documents() {
let mut server = common::Server::with_uid("movies");
let mut server = common::Server::with_uid("test");
let body = json!({
"uid": "movies",
"uid": "test",
"primaryKey": "id",
});
server.create_index(body).await;
// 1 - Add ranking rules with one custom ranking on a string
let body = json!(["asc(title)", "typo"]);
let body = json!(["asc(name)", "typo"]);
server.update_ranking_rules(body).await;
@ -157,13 +155,13 @@ async fn write_custom_ranking_and_index_documents() {
let body = json!([
{
"id": 1,
"title": "Le Petit Prince",
"author": "Exupéry"
"name": "Cherry Orr",
"color": "green"
},
{
"id": 2,
"title": "Pride and Prejudice",
"author": "Jane Austen"
"name": "Lucas Hess",
"color": "yellow"
}
]);
@ -173,7 +171,7 @@ async fn write_custom_ranking_and_index_documents() {
let expected = json!({
"id": 1,
"author": "Exupéry"
"color": "green"
});
let (response, status_code) = server.get_document(1).await;

View File

@ -5,8 +5,7 @@ mod common;
#[actix_rt::test]
async fn update_stop_words() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
// 1 - Get stop words
@ -15,7 +14,7 @@ async fn update_stop_words() {
// 2 - Update stop words
let body = json!(["the", "a"]);
let body = json!(["ut", "ea"]);
server.update_stop_words(body.clone()).await;
// 3 - Get all stop words and compare to the previous one
@ -35,22 +34,21 @@ async fn update_stop_words() {
#[actix_rt::test]
async fn add_documents_and_stop_words() {
let mut server = common::Server::with_uid("movies");
server.populate_movies().await;
let mut server = common::Server::test_server().await;
// 2 - Update stop words
let body = json!(["the", "of"]);
let body = json!(["ad", "in"]);
server.update_stop_words(body.clone()).await;
// 3 - Search for a document with stop words
let (response, _status_code) = server.search_get("q=the%20mask").await;
let (response, _status_code) = server.search_get("q=in%20exercitation").await;
assert!(!response["hits"].as_array().unwrap().is_empty());
// 4 - Search for documents with *only* stop words
let (response, _status_code) = server.search_get("q=the%20of").await;
let (response, _status_code) = server.search_get("q=ad%20in").await;
assert!(response["hits"].as_array().unwrap().is_empty());
// 5 - Delete all stop words