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)] 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!({