tests get one document

This commit is contained in:
mpostma 2021-02-22 14:32:48 +01:00
parent 097cae90a7
commit ded6483173
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A

View File

@ -13,6 +13,41 @@ async fn get_unexisting_index_single_document() {
assert_eq!(code, 400); assert_eq!(code, 400);
} }
#[actix_rt::test]
async fn get_unexisting_document() {
let server = Server::new().await;
let index = server.index("test");
index.create(None).await;
let (_response, code) = index
.get_document(1, None)
.await;
assert_eq!(code, 400);
}
#[actix_rt::test]
async fn get_document() {
let server = Server::new().await;
let index = server.index("test");
index.create(None).await;
let documents = serde_json::json!([
{
"id": 0,
"content": "foobar",
}
]);
let (_, code) = index.add_documents(documents, None).await;
assert_eq!(code, 200);
index.wait_update_id(0).await;
let (response, code) = index
.get_document(0, None)
.await;
assert_eq!(code, 200);
assert_eq!(response, serde_json::json!( {
"id": 0,
"content": "foobar",
}));
}
#[actix_rt::test] #[actix_rt::test]
async fn get_unexisting_index_all_documents() { async fn get_unexisting_index_all_documents() {
let server = Server::new().await; let server = Server::new().await;