From 9681ffca524defa8889135c0e3857cfbe27b8f96 Mon Sep 17 00:00:00 2001 From: mpostma Date: Mon, 5 Jul 2021 10:10:17 +0200 Subject: [PATCH 1/2] change index create http code --- meilisearch-http/src/routes/indexes/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meilisearch-http/src/routes/indexes/mod.rs b/meilisearch-http/src/routes/indexes/mod.rs index 89fa366cb..260d97ecd 100644 --- a/meilisearch-http/src/routes/indexes/mod.rs +++ b/meilisearch-http/src/routes/indexes/mod.rs @@ -54,7 +54,7 @@ async fn create_index( ) -> Result { let body = body.into_inner(); let meta = data.create_index(body.uid, body.primary_key).await?; - Ok(HttpResponse::Ok().json(meta)) + Ok(HttpResponse::Created().json(meta)) } #[derive(Debug, Deserialize)] @@ -73,6 +73,7 @@ pub struct UpdateIndexResponse { updated_at: DateTime, primary_key: Option, } + async fn get_index( data: GuardedData, path: web::Path, From 2f3a439566a3257c6722d6b3eca367e84e559f1e Mon Sep 17 00:00:00 2001 From: mpostma Date: Mon, 5 Jul 2021 11:21:02 +0200 Subject: [PATCH 2/2] fix tests --- meilisearch-http/tests/documents/get_documents.rs | 2 +- meilisearch-http/tests/index/create_index.rs | 6 +++--- meilisearch-http/tests/index/delete_index.rs | 2 +- meilisearch-http/tests/index/get_index.rs | 2 +- meilisearch-http/tests/index/stats.rs | 2 +- meilisearch-http/tests/index/update_index.rs | 6 +++--- meilisearch-http/tests/settings/get_settings.rs | 2 +- meilisearch-http/tests/stats/mod.rs | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/meilisearch-http/tests/documents/get_documents.rs b/meilisearch-http/tests/documents/get_documents.rs index 945bd6b5c..14344db35 100644 --- a/meilisearch-http/tests/documents/get_documents.rs +++ b/meilisearch-http/tests/documents/get_documents.rs @@ -61,7 +61,7 @@ async fn get_no_documents() { let server = Server::new().await; let index = server.index("test"); let (_, code) = index.create(None).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (response, code) = index .get_all_documents(GetAllDocumentsOptions::default()) diff --git a/meilisearch-http/tests/index/create_index.rs b/meilisearch-http/tests/index/create_index.rs index e65908cb2..3c081f0ed 100644 --- a/meilisearch-http/tests/index/create_index.rs +++ b/meilisearch-http/tests/index/create_index.rs @@ -7,7 +7,7 @@ async fn create_index_no_primary_key() { let index = server.index("test"); let (response, code) = index.create(None).await; - assert_eq!(code, 200); + assert_eq!(code, 201); assert_eq!(response["uid"], "test"); assert_eq!(response["name"], "test"); assert!(response.get("createdAt").is_some()); @@ -23,7 +23,7 @@ async fn create_index_with_primary_key() { let index = server.index("test"); let (response, code) = index.create(Some("primary")).await; - assert_eq!(code, 200); + assert_eq!(code, 201); assert_eq!(response["uid"], "test"); assert_eq!(response["name"], "test"); assert!(response.get("createdAt").is_some()); @@ -41,7 +41,7 @@ async fn create_existing_index() { let index = server.index("test"); let (_, code) = index.create(Some("primary")).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (_response, code) = index.create(Some("primary")).await; assert_eq!(code, 400); diff --git a/meilisearch-http/tests/index/delete_index.rs b/meilisearch-http/tests/index/delete_index.rs index 6ce9587fc..10a6c0282 100644 --- a/meilisearch-http/tests/index/delete_index.rs +++ b/meilisearch-http/tests/index/delete_index.rs @@ -8,7 +8,7 @@ async fn create_and_delete_index() { let index = server.index("test"); let (_response, code) = index.create(None).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (_response, code) = index.delete().await; diff --git a/meilisearch-http/tests/index/get_index.rs b/meilisearch-http/tests/index/get_index.rs index a6b22509e..ba26a8e3a 100644 --- a/meilisearch-http/tests/index/get_index.rs +++ b/meilisearch-http/tests/index/get_index.rs @@ -7,7 +7,7 @@ async fn create_and_get_index() { let index = server.index("test"); let (_, code) = index.create(None).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (response, code) = index.get().await; diff --git a/meilisearch-http/tests/index/stats.rs b/meilisearch-http/tests/index/stats.rs index 8494bbae3..3599e1605 100644 --- a/meilisearch-http/tests/index/stats.rs +++ b/meilisearch-http/tests/index/stats.rs @@ -8,7 +8,7 @@ async fn stats() { let index = server.index("test"); let (_, code) = index.create(Some("id")).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (response, code) = index.stats().await; diff --git a/meilisearch-http/tests/index/update_index.rs b/meilisearch-http/tests/index/update_index.rs index c7d910b59..454b55fce 100644 --- a/meilisearch-http/tests/index/update_index.rs +++ b/meilisearch-http/tests/index/update_index.rs @@ -7,7 +7,7 @@ async fn update_primary_key() { let index = server.index("test"); let (_, code) = index.create(None).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (response, code) = index.update(Some("primary")).await; @@ -31,7 +31,7 @@ async fn update_nothing() { let index = server.index("test"); let (response, code) = index.create(None).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (update, code) = index.update(None).await; @@ -47,7 +47,7 @@ async fn update_existing_primary_key() { let index = server.index("test"); let (_response, code) = index.create(Some("primary")).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (_update, code) = index.update(Some("primary2")).await; diff --git a/meilisearch-http/tests/settings/get_settings.rs b/meilisearch-http/tests/settings/get_settings.rs index 0b523eef3..837c90cc1 100644 --- a/meilisearch-http/tests/settings/get_settings.rs +++ b/meilisearch-http/tests/settings/get_settings.rs @@ -206,7 +206,7 @@ macro_rules! test_setting_routes { let server = Server::new().await; let index = server.index("test"); let (response, code) = index.create(None).await; - assert_eq!(code, 200, "{}", response); + assert_eq!(code, 201, "{}", response); let url = format!("/indexes/test/settings/{}", stringify!($setting) .chars() diff --git a/meilisearch-http/tests/stats/mod.rs b/meilisearch-http/tests/stats/mod.rs index aba860256..39c59fb27 100644 --- a/meilisearch-http/tests/stats/mod.rs +++ b/meilisearch-http/tests/stats/mod.rs @@ -28,7 +28,7 @@ async fn stats() { let index = server.index("test"); let (_, code) = index.create(Some("id")).await; - assert_eq!(code, 200); + assert_eq!(code, 201); let (response, code) = server.stats().await;