mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-06 04:36:32 +00:00
Update tests
This commit is contained in:
@ -375,6 +375,11 @@ impl<State> Index<'_, State> {
|
|||||||
self.service.get(url).await
|
self.service.get(url).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn delete_tasks(&self, query: impl AsRef<str>) -> (Value, StatusCode) {
|
||||||
|
let url = format!("/tasks?{}", query.as_ref());
|
||||||
|
self.service.delete(url).await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn filtered_tasks(
|
pub async fn filtered_tasks(
|
||||||
&self,
|
&self,
|
||||||
types: &[&str],
|
types: &[&str],
|
||||||
|
@ -160,7 +160,9 @@ pub trait IntoTaskUid {
|
|||||||
|
|
||||||
impl IntoTaskUid for Value {
|
impl IntoTaskUid for Value {
|
||||||
fn uid(&self) -> u64 {
|
fn uid(&self) -> u64 {
|
||||||
self["taskUid"].as_u64().expect("Value must contain a taskUid")
|
self["taskUid"].as_u64().unwrap_or_else(|| {
|
||||||
|
panic!("Called `uid` on a Value that doesn't contain a taskUid: {self}")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ async fn delete_task() {
|
|||||||
|
|
||||||
// Delete tasks
|
// Delete tasks
|
||||||
let (task, code) = index.delete_tasks(format!("uids={task_uid}")).await;
|
let (task, code) = index.delete_tasks(format!("uids={task_uid}")).await;
|
||||||
snapshot!(code, @"200 OK");
|
snapshot!(code, @"202 Accepted");
|
||||||
let value = server.wait_task(task).await.succeeded();
|
let value = server.wait_task(task).await.succeeded();
|
||||||
snapshot!(value, @r#"
|
snapshot!(value, @r#"
|
||||||
{
|
{
|
||||||
@ -75,7 +75,7 @@ async fn delete_task() {
|
|||||||
"details": {
|
"details": {
|
||||||
"matchedTasks": 1,
|
"matchedTasks": 1,
|
||||||
"deletedTasks": 1,
|
"deletedTasks": 1,
|
||||||
"originalFilter": "?uids=0"
|
"originalFilter": "?uids=4"
|
||||||
},
|
},
|
||||||
"error": null,
|
"error": null,
|
||||||
"duration": "[duration]",
|
"duration": "[duration]",
|
||||||
@ -102,7 +102,7 @@ async fn delete_task() {
|
|||||||
// If there is a bug it's caused by a combination of the parameters so let's test them together!
|
// If there is a bug it's caused by a combination of the parameters so let's test them together!
|
||||||
|
|
||||||
async fn delete_tasks_time_bounds_inner(name: &str) {
|
async fn delete_tasks_time_bounds_inner(name: &str) {
|
||||||
let server = Server::new_shared();
|
let server = Server::new().await;
|
||||||
let index = server.unique_index();
|
let index = server.unique_index();
|
||||||
|
|
||||||
// Add documents
|
// Add documents
|
||||||
@ -139,21 +139,18 @@ async fn delete_tasks_time_bounds_inner(name: &str) {
|
|||||||
encode(&time1.format(&Rfc3339).unwrap()),
|
encode(&time1.format(&Rfc3339).unwrap()),
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
snapshot!(code, @"200 OK");
|
snapshot!(code, @"202 Accepted");
|
||||||
let value = server.wait_task(task).await.succeeded();
|
let value = server.wait_task(task).await.succeeded();
|
||||||
|
|
||||||
snapshot!(json_string!(value, {
|
snapshot!(json_string!(value, {
|
||||||
".details.originalFilter" => "[ignored]",
|
".details.originalFilter" => "[ignored]",
|
||||||
".uid" => "[ignored]",
|
|
||||||
".batchUid" => "[ignored]",
|
|
||||||
".duration" => "[duration]",
|
".duration" => "[duration]",
|
||||||
".enqueuedAt" => "[date]",
|
".enqueuedAt" => "[date]",
|
||||||
".startedAt" => "[date]",
|
".startedAt" => "[date]",
|
||||||
".finishedAt" => "[date]"
|
".finishedAt" => "[date]"
|
||||||
}), @r#"
|
}), @r#"
|
||||||
{
|
{
|
||||||
"uid": "[ignored]",
|
"uid": 6,
|
||||||
"batchUid": "[ignored]",
|
"batchUid": 6,
|
||||||
"indexUid": null,
|
"indexUid": null,
|
||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
"type": "taskDeletion",
|
"type": "taskDeletion",
|
||||||
@ -172,21 +169,38 @@ async fn delete_tasks_time_bounds_inner(name: &str) {
|
|||||||
"#);
|
"#);
|
||||||
|
|
||||||
// Check that the task is deleted
|
// Check that the task is deleted
|
||||||
let (value, code) = index.list_tasks().await;
|
let (value, code) = server.tasks().await;
|
||||||
snapshot!(code, @r#"200 OK"#);
|
snapshot!(code, @r#"200 OK"#);
|
||||||
snapshot!(json_string!(value, {
|
snapshot!(json_string!(value, {
|
||||||
".results[].uid" => "[ignored]",
|
|
||||||
".results[].batchUid" => "[ignored]",
|
|
||||||
".results[].duration" => "[duration]",
|
".results[].duration" => "[duration]",
|
||||||
".results[].enqueuedAt" => "[date]",
|
".results[].enqueuedAt" => "[date]",
|
||||||
".results[].startedAt" => "[date]",
|
".results[].startedAt" => "[date]",
|
||||||
".results[].finishedAt" => "[date]"
|
".results[].finishedAt" => "[date]",
|
||||||
|
".results[].details.originalFilter" => "[ignored]"
|
||||||
}), @r#"
|
}), @r#"
|
||||||
{
|
{
|
||||||
"results": [
|
"results": [
|
||||||
{
|
{
|
||||||
"uid": "[ignored]",
|
"uid": 6,
|
||||||
"batchUid": "[ignored]",
|
"batchUid": 6,
|
||||||
|
"indexUid": null,
|
||||||
|
"status": "succeeded",
|
||||||
|
"type": "taskDeletion",
|
||||||
|
"canceledBy": null,
|
||||||
|
"details": {
|
||||||
|
"matchedTasks": 2,
|
||||||
|
"deletedTasks": 2,
|
||||||
|
"originalFilter": "[ignored]"
|
||||||
|
},
|
||||||
|
"error": null,
|
||||||
|
"duration": "[duration]",
|
||||||
|
"enqueuedAt": "[date]",
|
||||||
|
"startedAt": "[date]",
|
||||||
|
"finishedAt": "[date]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uid": 5,
|
||||||
|
"batchUid": 5,
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "[uuid]",
|
||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
"type": "documentAdditionOrUpdate",
|
"type": "documentAdditionOrUpdate",
|
||||||
@ -202,8 +216,8 @@ async fn delete_tasks_time_bounds_inner(name: &str) {
|
|||||||
"finishedAt": "[date]"
|
"finishedAt": "[date]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "[ignored]",
|
"uid": 4,
|
||||||
"batchUid": "[ignored]",
|
"batchUid": 4,
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "[uuid]",
|
||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
"type": "documentAdditionOrUpdate",
|
"type": "documentAdditionOrUpdate",
|
||||||
@ -219,8 +233,8 @@ async fn delete_tasks_time_bounds_inner(name: &str) {
|
|||||||
"finishedAt": "[date]"
|
"finishedAt": "[date]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "[ignored]",
|
"uid": 1,
|
||||||
"batchUid": "[ignored]",
|
"batchUid": 1,
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "[uuid]",
|
||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
"type": "documentAdditionOrUpdate",
|
"type": "documentAdditionOrUpdate",
|
||||||
@ -236,8 +250,8 @@ async fn delete_tasks_time_bounds_inner(name: &str) {
|
|||||||
"finishedAt": "[date]"
|
"finishedAt": "[date]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "[ignored]",
|
"uid": 0,
|
||||||
"batchUid": "[ignored]",
|
"batchUid": 0,
|
||||||
"indexUid": "[uuid]",
|
"indexUid": "[uuid]",
|
||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
"type": "documentAdditionOrUpdate",
|
"type": "documentAdditionOrUpdate",
|
||||||
@ -253,17 +267,27 @@ async fn delete_tasks_time_bounds_inner(name: &str) {
|
|||||||
"finishedAt": "[date]"
|
"finishedAt": "[date]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"total": 4,
|
"total": 5,
|
||||||
"limit": 20,
|
"limit": 20,
|
||||||
"from": 12,
|
"from": 6,
|
||||||
"next": null
|
"next": null
|
||||||
}
|
}
|
||||||
"#);
|
"#);
|
||||||
|
|
||||||
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn delete_tasks_time_bounds() {
|
async fn delete_tasks_enqueued() {
|
||||||
delete_tasks_time_bounds_inner("EnqueuedAt").await;
|
delete_tasks_time_bounds_inner("EnqueuedAt").await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn delete_tasks_started() {
|
||||||
delete_tasks_time_bounds_inner("StartedAt").await;
|
delete_tasks_time_bounds_inner("StartedAt").await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn delete_tasks_finished() {
|
||||||
delete_tasks_time_bounds_inner("FinishedAt").await;
|
delete_tasks_time_bounds_inner("FinishedAt").await;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user