update all the response format to be ISO with meilisearch, see #64

This commit is contained in:
Irevoire 2021-03-17 13:54:17 +01:00 committed by tamo
parent 6e1ddfea5a
commit 96cffeab1e
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
5 changed files with 43 additions and 28 deletions

View file

@ -23,7 +23,7 @@ impl Index<'_> {
.service
.post_str(url, include_str!("../assets/test_set.json"))
.await;
assert_eq!(code, 200);
assert_eq!(code, 202);
let update_id = response["updateId"].as_i64().unwrap();
self.wait_update_id(update_id as u64).await;
update_id as u64

View file

@ -16,13 +16,16 @@ async fn add_documents_no_index_creation() {
]);
let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 200);
assert_eq!(response["status"], "pending");
assert_eq!(code, 202);
assert_eq!(response["updateId"], 0);
assert_eq!(response["meta"]["type"], "DocumentsAddition");
assert_eq!(response["meta"]["format"], "Json");
assert_eq!(response["meta"]["primaryKey"], Value::Null);
assert!(response.get("enqueuedAt").is_some());
/*
* currently we dont check these field to stay ISO with meilisearch
* assert_eq!(response["status"], "pending");
* assert_eq!(response["meta"]["type"], "DocumentsAddition");
* assert_eq!(response["meta"]["format"], "Json");
* assert_eq!(response["meta"]["primaryKey"], Value::Null);
* assert!(response.get("enqueuedAt").is_some());
*/
index.wait_update_id(0).await;
@ -75,7 +78,7 @@ async fn document_addition_with_primary_key() {
}
]);
let (_response, code) = index.add_documents(documents, Some("primary")).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(0).await;
@ -102,7 +105,7 @@ async fn document_update_with_primary_key() {
}
]);
let (_response, code) = index.update_documents(documents, Some("primary")).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(0).await;
@ -131,7 +134,7 @@ async fn add_documents_with_primary_key_and_primary_key_already_exists() {
]);
let (_response, code) = index.add_documents(documents, Some("id")).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(0).await;
@ -160,7 +163,7 @@ async fn update_documents_with_primary_key_and_primary_key_already_exists() {
]);
let (_response, code) = index.update_documents(documents, Some("id")).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(0).await;
let (response, code) = index.get_update(0).await;
@ -187,7 +190,7 @@ async fn replace_document() {
]);
let (_response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(0).await;
@ -199,7 +202,7 @@ async fn replace_document() {
]);
let (_response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(1).await;
@ -246,7 +249,7 @@ async fn update_document() {
]);
let (_response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(0).await;
@ -258,7 +261,7 @@ async fn update_document() {
]);
let (_response, code) = index.update_documents(documents, None).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(1).await;

View file

@ -15,7 +15,7 @@ async fn delete_one_unexisting_document() {
let index = server.index("test");
index.create(None).await;
let (_response, code) = index.delete_document(0).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
let update = index.wait_update_id(0).await;
assert_eq!(update["status"], "processed");
}
@ -29,7 +29,7 @@ async fn delete_one_document() {
.await;
index.wait_update_id(0).await;
let (_response, code) = server.index("test").delete_document(0).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(1).await;
let (_response, code) = index.get_document(0, None).await;
@ -55,7 +55,7 @@ async fn clear_all_documents() {
.await;
index.wait_update_id(0).await;
let (_response, code) = index.clear_all_documents().await;
assert_eq!(code, 200);
assert_eq!(code, 202);
let _update = index.wait_update_id(1).await;
let (response, code) = index
@ -72,7 +72,7 @@ async fn clear_all_documents_empty_index() {
index.create(None).await;
let (_response, code) = index.clear_all_documents().await;
assert_eq!(code, 200);
assert_eq!(code, 202);
let _update = index.wait_update_id(0).await;
let (response, code) = index
@ -96,7 +96,7 @@ async fn delete_batch() {
index.add_documents(json!([{ "id": 1, "content": "foobar" }, { "id": 0, "content": "foobar" }, { "id": 3, "content": "foobar" }]), Some("id")).await;
index.wait_update_id(0).await;
let (_response, code) = index.delete_batch(vec![1, 0]).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
let _update = index.wait_update_id(1).await;
let (response, code) = index
@ -114,7 +114,7 @@ async fn delete_no_document_batch() {
index.add_documents(json!([{ "id": 1, "content": "foobar" }, { "id": 0, "content": "foobar" }, { "id": 3, "content": "foobar" }]), Some("id")).await;
index.wait_update_id(0).await;
let (_response, code) = index.delete_batch(vec![]).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
let _update = index.wait_update_id(1).await;
let (response, code) = index

View file

@ -33,7 +33,7 @@ async fn get_document() {
}
]);
let (_, code) = index.add_documents(documents, None).await;
assert_eq!(code, 200);
assert_eq!(code, 202);
index.wait_update_id(0).await;
let (response, code) = index.get_document(0, None).await;
assert_eq!(code, 200);