From 11e00c906f185ecfb4653c6fdbdd84061cd39fb6 Mon Sep 17 00:00:00 2001 From: mpostma Date: Fri, 5 Jun 2020 11:33:59 +0200 Subject: [PATCH 1/2] error when deleting unexisting index --- meilisearch-http/src/routes/index.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/meilisearch-http/src/routes/index.rs b/meilisearch-http/src/routes/index.rs index 25fd3f17f..d3f30711c 100644 --- a/meilisearch-http/src/routes/index.rs +++ b/meilisearch-http/src/routes/index.rs @@ -311,9 +311,11 @@ async fn delete_index( data: web::Data, path: web::Path, ) -> Result { - data.db.delete_index(&path.index_uid)?; - - Ok(HttpResponse::NoContent().finish()) + if data.db.delete_index(&path.index_uid)? { + Ok(HttpResponse::NoContent().finish()) + } else { + Err(Error::index_not_found(&path.index_uid).into()) + } } #[derive(Deserialize)] From 56b01ba440dd5f1a689169edd55697bcb702b9c6 Mon Sep 17 00:00:00 2001 From: mpostma Date: Fri, 5 Jun 2020 11:40:18 +0200 Subject: [PATCH 2/2] test error delete unexisting index --- meilisearch-http/tests/index.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meilisearch-http/tests/index.rs b/meilisearch-http/tests/index.rs index be8193613..babe0e7aa 100644 --- a/meilisearch-http/tests/index.rs +++ b/meilisearch-http/tests/index.rs @@ -195,6 +195,12 @@ async fn rename_index() { async fn delete_index_and_recreate_it() { let mut server = common::Server::with_uid("movies"); + // 0 - delete unexisting index is error + + let (response, status_code) = server.delete_request("/indexes/test").await; + assert_eq!(status_code, 404); + assert_eq!(&response["errorCode"], "index_not_found"); + // 1 - Create a new index let body = json!({