test index delete

This commit is contained in:
mpostma 2021-02-18 20:44:33 +01:00
parent ed3f8f5cc0
commit b293948d36
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A
5 changed files with 25 additions and 30 deletions

View File

@ -33,4 +33,9 @@ impl Index<'_> {
self.service.put(url, body).await
}
pub async fn delete(&self) -> (Value, StatusCode) {
let url = format!("/indexes/{}", self.uid);
self.service.delete(url).await
}
}

View File

@ -138,22 +138,6 @@ impl Server {
// Global Http request GET/POST/DELETE async or sync
//pub async fn get_request(&mut self, url: &str) -> (Value, StatusCode) {
//eprintln!("get_request: {}", url);
//let mut app =
//test::init_service(meilisearch_http::create_app(&self.data, true).wrap(NormalizePath)).await;
//let req = test::TestRequest::get().uri(url).to_request();
//let res = test::call_service(&mut app, req).await;
//let status_code = res.status();
//let body = test::read_body(res).await;
//let response = serde_json::from_slice(&body).unwrap_or_default();
//(response, status_code)
//}
//pub async fn post_request_async(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
//eprintln!("post_request_async: {}", url);
@ -177,20 +161,6 @@ impl Server {
//(response, status_code)
//}
//pub async fn delete_request(&mut self, url: &str) -> (Value, StatusCode) {
//eprintln!("delete_request: {}", url);
//let mut app =
//test::init_service(meilisearch_http::create_app(&self.data, true).wrap(NormalizePath)).await;
//let req = test::TestRequest::delete().uri(url).to_request();
//let res = test::call_service(&mut app, req).await;
//let status_code = res.status();
//let body = test::read_body(res).await;
//let response = serde_json::from_slice(&body).unwrap_or_default();
//(response, status_code)
//}
//pub async fn delete_request_async(&mut self, url: &str) -> (Value, StatusCode) {
//eprintln!("delete_request_async: {}", url);

View File

@ -51,5 +51,18 @@ impl Service {
let response = serde_json::from_slice(&body).unwrap_or_default();
(response, status_code)
}
pub async fn delete(&self, url: impl AsRef<str>) -> (Value, StatusCode) {
let mut app =
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
let req = test::TestRequest::delete().uri(url.as_ref()).to_request();
let res = test::call_service(&mut app, req).await;
let status_code = res.status();
let body = test::read_body(res).await;
let response = serde_json::from_slice(&body).unwrap_or_default();
(response, status_code)
}
}

View File

@ -1,3 +1,4 @@
mod create_index;
mod get_index;
mod update_index;
mod delete_index;

View File

@ -1,3 +1,9 @@
mod common;
mod search;
mod index;
// Tests are isolated by features in different modules to allow better readability, test
// targetability, and improved incremental compilation times.
//
// All the integration tests live in the same root module so only one test executable is generated,
// thus improving linking time.