mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
fix the tests
This commit is contained in:
parent
27155f845c
commit
8ff15b3dfb
6 changed files with 88 additions and 101 deletions
|
@ -143,23 +143,19 @@ async fn list_batches_status_filtered() {
|
|||
let index = server.index("test");
|
||||
let (task, _status_code) = index.create(None).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
let (task, _status_code) = index
|
||||
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
|
||||
.await;
|
||||
let (task, _status_code) = index.create(None).await;
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
|
||||
let (response, code) = index.filtered_batches(&[], &["succeeded"], &[]).await;
|
||||
assert_eq!(code, 200, "{}", response);
|
||||
assert_eq!(response["results"].as_array().unwrap().len(), 1);
|
||||
|
||||
// We can't be sure that the update isn't already processed so we can't test this
|
||||
// let (response, code) = index.filtered_batches(&[], &["processing"]).await;
|
||||
// assert_eq!(code, 200, "{}", response);
|
||||
// assert_eq!(response["results"].as_array().unwrap().len(), 1);
|
||||
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
|
||||
let (response, code) = index.filtered_batches(&[], &["succeeded"], &[]).await;
|
||||
assert_eq!(code, 200, "{}", response);
|
||||
assert_eq!(response["results"].as_array().unwrap().len(), 1);
|
||||
|
||||
let (response, code) = index.filtered_batches(&[], &["succeeded", "failed"], &[]).await;
|
||||
assert_eq!(code, 200, "{}", response);
|
||||
assert_eq!(response["results"].as_array().unwrap().len(), 2);
|
||||
}
|
||||
|
||||
|
@ -176,9 +172,13 @@ async fn list_batches_type_filtered() {
|
|||
assert_eq!(response["results"].as_array().unwrap().len(), 1);
|
||||
|
||||
let (response, code) =
|
||||
index.filtered_batches(&["indexCreation", "documentAdditionOrUpdate"], &[], &[]).await;
|
||||
index.filtered_batches(&["indexCreation", "IndexDeletion"], &[], &[]).await;
|
||||
assert_eq!(code, 200, "{}", response);
|
||||
assert_eq!(response["results"].as_array().unwrap().len(), 2);
|
||||
|
||||
let (response, code) = index.filtered_batches(&["indexCreation"], &[], &[]).await;
|
||||
assert_eq!(code, 200, "{}", response);
|
||||
assert_eq!(response["results"].as_array().unwrap().len(), 1);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
|
@ -344,7 +344,7 @@ async fn test_summarized_delete_documents_by_batch() {
|
|||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
let (task, _status_code) = index.delete_batch(vec![1, 2, 3]).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = index.get_batch(0).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
|
@ -414,7 +414,7 @@ async fn test_summarized_delete_documents_by_filter() {
|
|||
|
||||
let (task, _status_code) =
|
||||
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = index.get_batch(0).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
|
@ -448,7 +448,7 @@ async fn test_summarized_delete_documents_by_filter() {
|
|||
index.create(None).await;
|
||||
let (task, _status_code) =
|
||||
index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = index.get_batch(2).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
|
@ -519,13 +519,12 @@ async fn test_summarized_delete_document_by_id() {
|
|||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
let (task, _status_code) = index.delete_document(1).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = index.get_batch(0).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
snapshot!(batch,
|
||||
@r#"
|
||||
{
|
||||
"uid": 0,
|
||||
"uid": "[uid]",
|
||||
"progress": null,
|
||||
"details": {
|
||||
"providedIds": 1,
|
||||
|
@ -672,7 +671,7 @@ async fn test_summarized_index_creation() {
|
|||
"#);
|
||||
|
||||
let (task, _status_code) = index.create(Some("doggos")).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = index.get_batch(1).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
|
@ -707,7 +706,7 @@ async fn test_summarized_index_deletion() {
|
|||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
let (ret, _code) = index.delete().await;
|
||||
let batch = index.wait_task(ret.uid()).await;
|
||||
let batch = index.wait_task(ret.uid()).await.failed();
|
||||
snapshot!(batch,
|
||||
@r###"
|
||||
{
|
||||
|
@ -738,7 +737,7 @@ async fn test_summarized_index_deletion() {
|
|||
// both batches may get autobatched and the deleted documents count will be wrong.
|
||||
let (ret, _code) =
|
||||
index.add_documents(json!({ "id": 42, "content": "doggos & fluff" }), Some("id")).await;
|
||||
let batch = index.wait_task(ret.uid()).await;
|
||||
let batch = index.wait_task(ret.uid()).await.succeeded();
|
||||
snapshot!(batch,
|
||||
@r###"
|
||||
{
|
||||
|
@ -761,7 +760,7 @@ async fn test_summarized_index_deletion() {
|
|||
"###);
|
||||
|
||||
let (ret, _code) = index.delete().await;
|
||||
let batch = index.wait_task(ret.uid()).await;
|
||||
let batch = index.wait_task(ret.uid()).await.succeeded();
|
||||
snapshot!(batch,
|
||||
@r###"
|
||||
{
|
||||
|
@ -784,7 +783,7 @@ async fn test_summarized_index_deletion() {
|
|||
|
||||
// What happens when you delete an index that doesn't exists.
|
||||
let (ret, _code) = index.delete().await;
|
||||
let batch = index.wait_task(ret.uid()).await;
|
||||
let batch = index.wait_task(ret.uid()).await.failed();
|
||||
snapshot!(batch,
|
||||
@r###"
|
||||
{
|
||||
|
@ -817,7 +816,7 @@ async fn test_summarized_index_update() {
|
|||
let index = server.index("test");
|
||||
// If the index doesn't exist yet, we should get errors with or without the primary key.
|
||||
let (task, _status_code) = index.update(None).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = index.get_batch(0).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
|
@ -845,7 +844,7 @@ async fn test_summarized_index_update() {
|
|||
"#);
|
||||
|
||||
let (task, _status_code) = index.update(Some("bones")).await;
|
||||
index.wait_task(task.uid()).await.succeeded();
|
||||
index.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = index.get_batch(1).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
|
@ -944,7 +943,7 @@ async fn test_summarized_index_swap() {
|
|||
{ "indexes": ["doggos", "cattos"] }
|
||||
]))
|
||||
.await;
|
||||
server.wait_task(task.uid()).await;
|
||||
server.wait_task(task.uid()).await.failed();
|
||||
let (batch, _) = server.get_batch(0).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
|
@ -985,33 +984,26 @@ async fn test_summarized_index_swap() {
|
|||
{ "indexes": ["doggos", "cattos"] }
|
||||
]))
|
||||
.await;
|
||||
server.wait_task(task.uid()).await;
|
||||
server.wait_task(task.uid()).await.succeeded();
|
||||
let (batch, _) = server.get_batch(1).await;
|
||||
assert_json_snapshot!(batch,
|
||||
{ ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" },
|
||||
@r#"
|
||||
{
|
||||
"uid": 3,
|
||||
"uid": 1,
|
||||
"progress": null,
|
||||
"details": {
|
||||
"swaps": [
|
||||
{
|
||||
"indexes": [
|
||||
"doggos",
|
||||
"cattos"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"details": {},
|
||||
"stats": {
|
||||
"totalNbTasks": 1,
|
||||
"status": {
|
||||
"succeeded": 1
|
||||
},
|
||||
"types": {
|
||||
"indexSwap": 1
|
||||
"indexCreation": 1
|
||||
},
|
||||
"indexUids": {}
|
||||
"indexUids": {
|
||||
"doggos": 1
|
||||
}
|
||||
},
|
||||
"duration": "[duration]",
|
||||
"startedAt": "[date]",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue