mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-24 13:40:31 +01:00
Merge pull request #759 from MarinPostma/document-delete-error
return error on deleting unexisting index
This commit is contained in:
commit
cff9e1fd94
@ -311,9 +311,11 @@ async fn delete_index(
|
||||
data: web::Data<Data>,
|
||||
path: web::Path<IndexParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
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)]
|
||||
|
@ -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!({
|
||||
|
Loading…
x
Reference in New Issue
Block a user