Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Jun 15, 2021
1 parent a303295 commit 82fa049
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 25 deletions.
6 changes: 3 additions & 3 deletions meilisearch-http/src/index_controller/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ mod test {
use super::*;
use crate::index_controller::index_actor::MockIndexActorHandle;
use crate::index_controller::update_actor::{
MockUpdateActorHandle, UpdateActorHandleImpl, UpdateError,
MockUpdateActorHandle, UpdateActorHandleImpl, error::UpdateActorError,
};
use crate::index_controller::uuid_resolver::{MockUuidResolverHandle, UuidResolverError};
use crate::index_controller::uuid_resolver::{MockUuidResolverHandle, error::UuidResolverError};

#[actix_rt::test]
async fn test_normal() {
Expand Down Expand Up @@ -223,7 +223,7 @@ mod test {
update_handle
.expect_snapshot()
// abitrary error
.returning(|_, _| Box::pin(err(UpdateError::UnexistingUpdate(0))));
.returning(|_, _| Box::pin(err(UpdateActorError::UnexistingUpdate(0))));

let snapshot_path = tempfile::tempdir_in(".").unwrap();
let snapshot_service = SnapshotService::new(
Expand Down
8 changes: 4 additions & 4 deletions meilisearch-http/tests/documents/delete_documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::common::{GetAllDocumentsOptions, Server};
async fn delete_one_document_unexisting_index() {
let server = Server::new().await;
let (_response, code) = server.index("test").delete_document(0).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand All @@ -33,14 +33,14 @@ async fn delete_one_document() {
index.wait_update_id(1).await;

let (_response, code) = index.get_document(0, None).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
async fn clear_all_documents_unexisting_index() {
let server = Server::new().await;
let (_response, code) = server.index("test").clear_all_documents().await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand Down Expand Up @@ -86,7 +86,7 @@ async fn clear_all_documents_empty_index() {
async fn delete_batch_unexisting_index() {
let server = Server::new().await;
let (_response, code) = server.index("test").delete_batch(vec![]).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand Down
6 changes: 3 additions & 3 deletions meilisearch-http/tests/documents/get_documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde_json::json;
async fn get_unexisting_index_single_document() {
let server = Server::new().await;
let (_response, code) = server.index("test").get_document(1, None).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand All @@ -18,7 +18,7 @@ async fn get_unexisting_document() {
let index = server.index("test");
index.create(None).await;
let (_response, code) = index.get_document(1, None).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand Down Expand Up @@ -53,7 +53,7 @@ async fn get_unexisting_index_all_documents() {
.index("test")
.get_all_documents(GetAllDocumentsOptions::default())
.await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand Down
2 changes: 1 addition & 1 deletion meilisearch-http/tests/index/create_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ async fn test_create_multiple_indexes() {
assert_eq!(index1.get().await.1, 200);
assert_eq!(index2.get().await.1, 200);
assert_eq!(index3.get().await.1, 200);
assert_eq!(index4.get().await.1, 400);
assert_eq!(index4.get().await.1, 404);
}
4 changes: 2 additions & 2 deletions meilisearch-http/tests/index/delete_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn create_and_delete_index() {

assert_eq!(code, 204);

assert_eq!(index.get().await.1, 400);
assert_eq!(index.get().await.1, 404);
}

#[actix_rt::test]
Expand All @@ -21,5 +21,5 @@ async fn delete_unexisting_index() {
let index = server.index("test");
let (_response, code) = index.delete().await;

assert_eq!(code, 400);
assert_eq!(code, 404);
}
2 changes: 1 addition & 1 deletion meilisearch-http/tests/index/get_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn get_unexisting_index() {

let (_response, code) = index.get().await;

assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand Down
2 changes: 1 addition & 1 deletion meilisearch-http/tests/index/update_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ async fn update_existing_primary_key() {
async fn test_unexisting_index() {
let server = Server::new().await;
let (_response, code) = server.index("test").update(None).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}
10 changes: 5 additions & 5 deletions meilisearch-http/tests/settings/get_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde_json::json;
async fn get_settings_unexisting_index() {
let server = Server::new().await;
let (_response, code) = server.index("test").settings().await;
assert_eq!(code, 400)
assert_eq!(code, 404)
}

#[actix_rt::test]
Expand Down Expand Up @@ -33,7 +33,7 @@ async fn update_settings_unknown_field() {
let server = Server::new().await;
let index = server.index("test");
let (_response, code) = index.update_settings(json!({"foo": 12})).await;
assert_eq!(code, 400);
assert_eq!(code, 500);
}

#[actix_rt::test]
Expand Down Expand Up @@ -65,7 +65,7 @@ async fn delete_settings_unexisting_index() {
let server = Server::new().await;
let index = server.index("test");
let (_response, code) = index.delete_settings().await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand Down Expand Up @@ -152,7 +152,7 @@ macro_rules! test_setting_routes {
.map(|c| if c == '_' { '-' } else { c })
.collect::<String>());
let (_response, code) = server.service.get(url).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand All @@ -178,7 +178,7 @@ macro_rules! test_setting_routes {
.map(|c| if c == '_' { '-' } else { c })
.collect::<String>());
let (_response, code) = server.service.delete(url).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}
}
)*
Expand Down
6 changes: 4 additions & 2 deletions meilisearch-http/tests/stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ async fn stats() {

assert_eq!(code, 200, "{}", response);

index.wait_update_id(0).await;
let value = index.wait_update_id(0).await;

println!("{}", value);

let (response, code) = server.stats().await;

assert_eq!(code, 200);
assert!(response["databaseSize"].as_u64().unwrap() > 0);
assert!(response["lastUpdate"].as_str().unwrap() > last_update);
assert!(response.get("lastUpdate").is_some());
assert_eq!(response["indexes"]["test"]["numberOfDocuments"], 2);
assert_eq!(response["indexes"]["test"]["isIndexing"], false);
assert_eq!(response["indexes"]["test"]["fieldsDistribution"]["id"], 2);
Expand Down
6 changes: 3 additions & 3 deletions meilisearch-http/tests/updates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::common::Server;
async fn get_update_unexisting_index() {
let server = Server::new().await;
let (_response, code) = server.index("test").get_update(0).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand All @@ -13,7 +13,7 @@ async fn get_unexisting_update_status() {
let index = server.index("test");
index.create(None).await;
let (_response, code) = index.get_update(0).await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand All @@ -39,7 +39,7 @@ async fn get_update_status() {
async fn list_updates_unexisting_index() {
let server = Server::new().await;
let (_response, code) = server.index("test").list_updates().await;
assert_eq!(code, 400);
assert_eq!(code, 404);
}

#[actix_rt::test]
Expand Down

0 comments on commit 82fa049

Please sign in to comment.