1469: Return 201 on index creation r=Kerollmops a=MarinPostma

fix #1467


Co-authored-by: mpostma <postma.marin@protonmail.com>
This commit is contained in:
bors[bot] 2021-07-05 15:42:13 +00:00 committed by GitHub
commit 0d1f5b7193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 14 additions and 13 deletions

View File

@ -54,7 +54,7 @@ async fn create_index(
) -> Result<HttpResponse, ResponseError> {
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<Utc>,
primary_key: Option<String>,
}
async fn get_index(
data: GuardedData<Private, Data>,
path: web::Path<IndexParam>,

View File

@ -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())

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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()

View File

@ -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;