Fix content type test

This commit is contained in:
many 2021-10-28 10:57:11 +02:00
parent 7464720426
commit 21f35762ca
No known key found for this signature in database
GPG Key ID: 2CEF23B75189EACA

View File

@ -8,7 +8,7 @@ use meilisearch_http::create_app;
use serde_json::{json, Value}; use serde_json::{json, Value};
#[actix_rt::test] #[actix_rt::test]
async fn strict_json_bad_content_type() { async fn error_json_bad_content_type() {
let routes = [ let routes = [
// all the POST routes except the dumps that can be created without any body or content-type // all the POST routes except the dumps that can be created without any body or content-type
// and the search that is not a strict json // and the search that is not a strict json
@ -69,10 +69,10 @@ async fn strict_json_bad_content_type() {
assert_eq!( assert_eq!(
response, response,
json!({ json!({
"message": r#"A Content-Type header is missing. Accepted values for the Content-Type header are: "application/json""#, "message": r#"A Content-Type header is missing. Accepted values for the Content-Type header are: `application/json`"#,
"errorCode": "missing_content_type", "code": "missing_content_type",
"errorType": "invalid_request_error", "type": "invalid_request",
"errorLink": "https://docs.meilisearch.com/errors#missing_content_type", "link": "https://docs.meilisearch.com/errors#missing_content_type",
}), }),
"when calling the route `{}` with no content-type", "when calling the route `{}` with no content-type",
route, route,
@ -91,16 +91,16 @@ async fn strict_json_bad_content_type() {
let response: Value = serde_json::from_slice(&body).unwrap_or_default(); let response: Value = serde_json::from_slice(&body).unwrap_or_default();
assert_eq!(status_code, 415); assert_eq!(status_code, 415);
let expected_error_message = format!( let expected_error_message = format!(
r#"The Content-Type "{}" is invalid. Accepted values for the Content-Type header are: "application/json""#, r#"The Content-Type `{}` is invalid. Accepted values for the Content-Type header are: `application/json`"#,
bad_content_type bad_content_type
); );
assert_eq!( assert_eq!(
response, response,
json!({ json!({
"message": expected_error_message, "message": expected_error_message,
"errorCode": "invalid_content_type", "code": "invalid_content_type",
"errorType": "invalid_request_error", "type": "invalid_request",
"errorLink": "https://docs.meilisearch.com/errors#invalid_content_type", "link": "https://docs.meilisearch.com/errors#invalid_content_type",
}), }),
"when calling the route `{}` with a content-type of `{}`", "when calling the route `{}` with a content-type of `{}`",
route, route,