fix tests

This commit is contained in:
marin postma 2021-06-15 22:21:52 +02:00
parent 0d3fb5ee0d
commit 0dfd1b74c8
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9
10 changed files with 23 additions and 22 deletions

View File

@ -143,7 +143,7 @@ mod test {
use crate::index_controller::update_actor::{
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() {

View File

@ -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]
@ -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]
@ -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]

View File

@ -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]
@ -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]
@ -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]

View File

@ -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);
}

View File

@ -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]
@ -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);
}

View File

@ -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]

View File

@ -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);
}

View File

@ -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]
@ -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]
@ -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]
@ -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]
@ -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);
}
}
)*

View File

@ -62,11 +62,12 @@ async fn stats() {
index.wait_update_id(0).await;
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!(response["indexes"]["test"]["isIndexing"] == false);
assert_eq!(response["indexes"]["test"]["fieldsDistribution"]["id"], 2);

View File

@ -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]
@ -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]
@ -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]