tests get one document
@@ -13,6 +13,41 @@ async fn get_unexisting_index_single_document() {
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]
async fn get_unexisting_index_all_documents() {
let server = Server::new().await;
