mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-12-02 18:15:38 +08: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>,
|
data: web::Data<Data>,
|
||||||
path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
data.db.delete_index(&path.index_uid)?;
|
if data.db.delete_index(&path.index_uid)? {
|
||||||
|
Ok(HttpResponse::NoContent().finish())
|
||||||
Ok(HttpResponse::NoContent().finish())
|
} else {
|
||||||
|
Err(Error::index_not_found(&path.index_uid).into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -195,6 +195,12 @@ async fn rename_index() {
|
|||||||
async fn delete_index_and_recreate_it() {
|
async fn delete_index_and_recreate_it() {
|
||||||
let mut server = common::Server::with_uid("movies");
|
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
|
// 1 - Create a new index
|
||||||
|
|
||||||
let body = json!({
|
let body = json!({
|
||||||
|
Loading…
Reference in New Issue
Block a user