diff --git a/tests/common/index.rs b/tests/common/index.rs index 5f297bbb5..0b80f3fde 100644 --- a/tests/common/index.rs +++ b/tests/common/index.rs @@ -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 + } } diff --git a/tests/common/server.rs b/tests/common/server.rs index 23aba5010..30d6c40fd 100644 --- a/tests/common/server.rs +++ b/tests/common/server.rs @@ -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); diff --git a/tests/common/service.rs b/tests/common/service.rs index 0ff1320df..b00552562 100644 --- a/tests/common/service.rs +++ b/tests/common/service.rs @@ -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) -> (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) + } } diff --git a/tests/index/mod.rs b/tests/index/mod.rs index 2aefd99c2..253afcfc4 100644 --- a/tests/index/mod.rs +++ b/tests/index/mod.rs @@ -1,3 +1,4 @@ mod create_index; mod get_index; mod update_index; +mod delete_index; diff --git a/tests/integration.rs b/tests/integration.rs index 2b8dc5612..9d9ba64e3 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -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.