Apply review suggestions

This commit is contained in:
Loïc Lecrenier 2023-01-11 14:31:34 +01:00 committed by Tamo
parent c91ffec72e
commit b0b7ad7caf
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
12 changed files with 236 additions and 251 deletions

View file

@ -1,4 +1,4 @@
use meili_snap::insta::{self, assert_debug_snapshot, assert_json_snapshot};
use meili_snap::insta::assert_json_snapshot;
use serde_json::json;
use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;
@ -179,7 +179,7 @@ async fn get_task_filter_error() {
let (response, code) = server.tasks_filter(json!( { "lol": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Query deserialize error: unknown field `lol`",
"code": "bad_request",
@ -190,7 +190,7 @@ async fn get_task_filter_error() {
let (response, code) = server.tasks_filter(json!( { "uids": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
"code": "invalid_task_uids",
@ -201,7 +201,7 @@ async fn get_task_filter_error() {
let (response, code) = server.tasks_filter(json!( { "from": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Query deserialize error: invalid digit found in string",
"code": "bad_request",
@ -212,7 +212,7 @@ async fn get_task_filter_error() {
let (response, code) = server.tasks_filter(json!( { "beforeStartedAt": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Task `beforeStartedAt` `pied` is invalid. It should follow the YYYY-MM-DD or RFC 3339 date-time format.",
"code": "invalid_task_before_started_at",
@ -228,7 +228,7 @@ async fn delete_task_filter_error() {
let (response, code) = server.delete_tasks(json!(null)).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Query parameters to filter the tasks to delete are missing. Available query parameters are: `uids`, `indexUids`, `statuses`, `types`, `beforeEnqueuedAt`, `afterEnqueuedAt`, `beforeStartedAt`, `afterStartedAt`, `beforeFinishedAt`, `afterFinishedAt`.",
"code": "missing_task_filters",
@ -239,7 +239,7 @@ async fn delete_task_filter_error() {
let (response, code) = server.delete_tasks(json!({ "lol": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Query deserialize error: unknown field `lol`",
"code": "bad_request",
@ -250,7 +250,7 @@ async fn delete_task_filter_error() {
let (response, code) = server.delete_tasks(json!({ "uids": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
"code": "invalid_task_uids",
@ -266,7 +266,7 @@ async fn cancel_task_filter_error() {
let (response, code) = server.cancel_tasks(json!(null)).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Query parameters to filter the tasks to cancel are missing. Available query parameters are: `uids`, `indexUids`, `statuses`, `types`, `beforeEnqueuedAt`, `afterEnqueuedAt`, `beforeStartedAt`, `afterStartedAt`, `beforeFinishedAt`, `afterFinishedAt`.",
"code": "missing_task_filters",
@ -277,7 +277,7 @@ async fn cancel_task_filter_error() {
let (response, code) = server.cancel_tasks(json!({ "lol": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Query deserialize error: unknown field `lol`",
"code": "bad_request",
@ -288,7 +288,7 @@ async fn cancel_task_filter_error() {
let (response, code) = server.cancel_tasks(json!({ "uids": "pied" })).await;
assert_eq!(code, 400, "{}", response);
insta::assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
"code": "invalid_task_uids",
@ -518,8 +518,8 @@ async fn test_summarized_settings_update() {
let index = server.index("test");
// here we should find my payload even in the failed task.
let (response, code) = index.update_settings(json!({ "rankingRules": ["custom"] })).await;
assert_debug_snapshot!(code, @"400");
assert_json_snapshot!(response, @r###"
meili_snap::snapshot!(code, @"400 Bad Request");
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{
"message": "`custom` ranking rule is invalid. Valid ranking rules are words, typo, sort, proximity, attribute, exactness and custom ranking rules. at `.rankingRules[0]`.",
"code": "invalid_settings_ranking_rules",