Rename the uid to taskUid in asynchronous response

This commit is contained in:
Kerollmops 2022-05-17 11:17:32 +02:00
parent e5ef5a6f9c
commit d2f457a076
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
9 changed files with 18 additions and 18 deletions

View File

@ -349,7 +349,7 @@ impl From<Vec<TaskView>> for TaskListView {
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct SummarizedTaskView { pub struct SummarizedTaskView {
uid: TaskId, task_uid: TaskId,
index_uid: Option<String>, index_uid: Option<String>,
status: TaskStatus, status: TaskStatus,
#[serde(rename = "type")] #[serde(rename = "type")]
@ -372,7 +372,7 @@ impl From<Task> for SummarizedTaskView {
}; };
Self { Self {
uid: other.id, task_uid: other.id,
index_uid: other.index_uid.map(|u| u.into_inner()), index_uid: other.index_uid.map(|u| u.into_inner()),
status: TaskStatus::Enqueued, status: TaskStatus::Enqueued,
task_type: other.content.into(), task_type: other.content.into(),

View File

@ -523,7 +523,7 @@ async fn error_creating_index_without_action() {
let (response, code) = index.add_documents(documents, None).await; let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202, "{:?}", response); assert_eq!(code, 202, "{:?}", response);
let task_id = response["uid"].as_u64().unwrap(); let task_id = response["taskUid"].as_u64().unwrap();
let response = index.wait_task(task_id).await; let response = index.wait_task(task_id).await;
assert_eq!(response["status"], "failed"); assert_eq!(response["status"], "failed");
@ -534,7 +534,7 @@ async fn error_creating_index_without_action() {
let (response, code) = index.update_settings(settings).await; let (response, code) = index.update_settings(settings).await;
assert_eq!(code, 202); assert_eq!(code, 202);
let task_id = response["uid"].as_u64().unwrap(); let task_id = response["taskUid"].as_u64().unwrap();
let response = index.wait_task(task_id).await; let response = index.wait_task(task_id).await;
@ -544,7 +544,7 @@ async fn error_creating_index_without_action() {
// try to create a index via add specialized settings route // try to create a index via add specialized settings route
let (response, code) = index.update_distinct_attribute(json!("test")).await; let (response, code) = index.update_distinct_attribute(json!("test")).await;
assert_eq!(code, 202); assert_eq!(code, 202);
let task_id = response["uid"].as_u64().unwrap(); let task_id = response["taskUid"].as_u64().unwrap();
let response = index.wait_task(task_id).await; let response = index.wait_task(task_id).await;
@ -583,7 +583,7 @@ async fn lazy_create_index() {
let (response, code) = index.add_documents(documents, None).await; let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202, "{:?}", response); assert_eq!(code, 202, "{:?}", response);
let task_id = response["uid"].as_u64().unwrap(); let task_id = response["taskUid"].as_u64().unwrap();
index.wait_task(task_id).await; index.wait_task(task_id).await;
@ -597,7 +597,7 @@ async fn lazy_create_index() {
let (response, code) = index.update_settings(settings).await; let (response, code) = index.update_settings(settings).await;
assert_eq!(code, 202); assert_eq!(code, 202);
let task_id = response["uid"].as_u64().unwrap(); let task_id = response["taskUid"].as_u64().unwrap();
index.wait_task(task_id).await; index.wait_task(task_id).await;
@ -609,7 +609,7 @@ async fn lazy_create_index() {
let index = server.index("test2"); let index = server.index("test2");
let (response, code) = index.update_distinct_attribute(json!("test")).await; let (response, code) = index.update_distinct_attribute(json!("test")).await;
assert_eq!(code, 202); assert_eq!(code, 202);
let task_id = response["uid"].as_u64().unwrap(); let task_id = response["taskUid"].as_u64().unwrap();
index.wait_task(task_id).await; index.wait_task(task_id).await;

View File

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

View File

@ -35,7 +35,7 @@ async fn add_documents_test_json_content_types() {
let body = test::read_body(res).await; let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default(); let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 202); assert_eq!(status_code, 202);
assert_eq!(response["uid"], 0); assert_eq!(response["taskUid"], 0);
// put // put
let req = test::TestRequest::put() let req = test::TestRequest::put()
@ -48,7 +48,7 @@ async fn add_documents_test_json_content_types() {
let body = test::read_body(res).await; let body = test::read_body(res).await;
let response: Value = serde_json::from_slice(&body).unwrap_or_default(); let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 202); assert_eq!(status_code, 202);
assert_eq!(response["uid"], 1); assert_eq!(response["taskUid"], 1);
} }
/// any other content-type is must be refused /// any other content-type is must be refused
@ -599,7 +599,7 @@ async fn add_documents_no_index_creation() {
let (response, code) = index.add_documents(documents, None).await; let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202); assert_eq!(code, 202);
assert_eq!(response["uid"], 0); assert_eq!(response["taskUid"], 0);
/* /*
* currently we dont check these field to stay ISO with meilisearch * currently we dont check these field to stay ISO with meilisearch
* assert_eq!(response["status"], "pending"); * assert_eq!(response["status"], "pending");

View File

@ -52,10 +52,10 @@ async fn loop_delete_add_documents() {
let mut tasks = Vec::new(); let mut tasks = Vec::new();
for _ in 0..50 { for _ in 0..50 {
let (response, code) = index.add_documents(documents.clone(), None).await; let (response, code) = index.add_documents(documents.clone(), None).await;
tasks.push(response["uid"].as_u64().unwrap()); tasks.push(response["taskUid"].as_u64().unwrap());
assert_eq!(code, 202, "{}", response); assert_eq!(code, 202, "{}", response);
let (response, code) = index.delete().await; let (response, code) = index.delete().await;
tasks.push(response["uid"].as_u64().unwrap()); tasks.push(response["taskUid"].as_u64().unwrap());
assert_eq!(code, 202, "{}", response); assert_eq!(code, 202, "{}", response);
} }

View File

@ -35,7 +35,7 @@ async fn stats() {
let (response, code) = index.add_documents(documents, None).await; let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202); assert_eq!(code, 202);
assert_eq!(response["uid"], 1); assert_eq!(response["taskUid"], 1);
index.wait_task(1).await; index.wait_task(1).await;

View File

@ -122,7 +122,7 @@ async fn reset_all_settings() {
let (response, code) = index.add_documents(documents, None).await; let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202); assert_eq!(code, 202);
assert_eq!(response["uid"], 0); assert_eq!(response["taskUid"], 0);
index.wait_task(0).await; index.wait_task(0).await;
index index

View File

@ -54,7 +54,7 @@ async fn stats() {
let (response, code) = index.add_documents(documents, None).await; let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202, "{}", response); assert_eq!(code, 202, "{}", response);
assert_eq!(response["uid"], 1); assert_eq!(response["taskUid"], 1);
index.wait_task(1).await; index.wait_task(1).await;

View File

@ -94,7 +94,7 @@ async fn list_tasks() {
macro_rules! assert_valid_summarized_task { macro_rules! assert_valid_summarized_task {
($response:expr, $task_type:literal, $index:literal) => {{ ($response:expr, $task_type:literal, $index:literal) => {{
assert_eq!($response.as_object().unwrap().len(), 5); assert_eq!($response.as_object().unwrap().len(), 5);
assert!($response["uid"].as_u64().is_some()); assert!($response["taskUid"].as_u64().is_some());
assert_eq!($response["indexUid"], $index); assert_eq!($response["indexUid"], $index);
assert_eq!($response["status"], "enqueued"); assert_eq!($response["status"], "enqueued");
assert_eq!($response["type"], $task_type); assert_eq!($response["type"], $task_type);