update settings tests to use the test dataset

This commit is contained in:
Balaji Sivaraman 2020-05-30 20:09:48 +05:30
parent 44fd9384bd
commit 643933c3b0

View File

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