update search_settings tests to use the test dataset

This commit is contained in:
Balaji Sivaraman 2020-06-27 16:19:19 +05:30
parent d55124e524
commit 60264763f4

View File

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