Fix all the tests

This commit is contained in:
Kerollmops 2022-10-26 15:07:59 +02:00 committed by Clément Renault
parent 314b89ca30
commit ee6597da60
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
4 changed files with 61 additions and 7 deletions

View File

@ -1,4 +1,4 @@
use std::collections::HashSet; use std::collections::BTreeSet;
use actix_web::web::Data; use actix_web::web::Data;
use actix_web::{web, HttpResponse}; use actix_web::{web, HttpResponse};
@ -29,10 +29,10 @@ pub async fn swap_indexes(
let search_rules = &index_scheduler.filters().search_rules; let search_rules = &index_scheduler.filters().search_rules;
let mut swaps = vec![]; let mut swaps = vec![];
let mut indexes_set = HashSet::<String>::default(); let mut indexes_set = BTreeSet::<String>::default();
let mut unauthorized_indexes = HashSet::new(); let mut unauthorized_indexes = BTreeSet::new();
let mut unknown_indexes = HashSet::new(); let mut unknown_indexes = BTreeSet::new();
let mut duplicate_indexes = HashSet::new(); let mut duplicate_indexes = BTreeSet::new();
for SwapIndexesPayload { indexes } in params.into_inner().into_iter() { for SwapIndexesPayload { indexes } in params.into_inner().into_iter() {
let (lhs, rhs) = match indexes.as_slice() { let (lhs, rhs) = match indexes.as_slice() {
[lhs, rhs] => (lhs, rhs), [lhs, rhs] => (lhs, rhs),

View File

@ -0,0 +1,52 @@
{"run_id":"1666789267-794995000","line":687,"new":{"module_name":"integration__tasks","snapshot_name":"summarized_index_swap","metadata":{"source":"meilisearch-http/tests/tasks/mod.rs","assertion_line":687,"expression":"v"},"snapshot":"{\n \"message\": \"Indexes `cattos`, `doggos` not found.\",\n \"code\": \"index_not_found\",\n \"type\": \"invalid_request\",\n \"link\": \"https://docs.meilisearch.com/errors#index_not_found\"\n}"},"old":{"module_name":"integration__tasks","metadata":{},"snapshot":"{\n \"message\": \"Indexes `doggos`, `cattos` not found.\",\n \"code\": \"index_not_found\",\n \"type\": \"invalid_request\",\n \"link\": \"https://docs.meilisearch.com/errors#index_not_found\"\n}"}}
{"run_id":"1666789267-794995000","line":582,"new":null,"old":null}
{"run_id":"1666789267-794995000","line":609,"new":null,"old":null}
{"run_id":"1666789267-794995000","line":639,"new":null,"old":null}
{"run_id":"1666789267-794995000","line":660,"new":null,"old":null}
{"run_id":"1666789267-794995000","line":389,"new":null,"old":null}
{"run_id":"1666789267-794995000","line":418,"new":null,"old":null}
{"run_id":"1666789267-794995000","line":741,"new":null,"old":null}
{"run_id":"1666789267-794995000","line":772,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":331,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":275,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":304,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":360,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":226,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":799,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":454,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":475,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":507,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":248,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":533,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":555,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":687,"new":{"module_name":"integration__tasks","snapshot_name":"summarized_index_swap","metadata":{"source":"meilisearch-http/tests/tasks/mod.rs","assertion_line":687,"expression":"v"},"snapshot":"{\n \"message\": \"Indexes `cattos`, `doggos` not found.\",\n \"code\": \"index_not_found\",\n \"type\": \"invalid_request\",\n \"link\": \"https://docs.meilisearch.com/errors#index_not_found\"\n}"},"old":{"module_name":"integration__tasks","metadata":{},"snapshot":"{\n \"message\": \"Indexes `doggos`, `cattos` not found.\",\n \"code\": \"index_not_found\",\n \"type\": \"invalid_request\",\n \"link\": \"https://docs.meilisearch.com/errors#index_not_found\"\n}"}}
{"run_id":"1666789494-111527000","line":582,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":389,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":609,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":418,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":639,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":660,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":741,"new":null,"old":null}
{"run_id":"1666789494-111527000","line":772,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":275,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":331,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":360,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":304,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":799,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":454,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":226,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":475,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":507,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":687,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":705,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":582,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":609,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":639,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":660,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":389,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":418,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":741,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":772,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":248,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":533,"new":null,"old":null}
{"run_id":"1666789656-901749000","line":555,"new":null,"old":null}

View File

@ -686,7 +686,7 @@ async fn test_summarized_index_swap() {
.await; .await;
assert_json_snapshot!(v, @r###" assert_json_snapshot!(v, @r###"
{ {
"message": "Indexes `doggos`, `cattos` not found.", "message": "Indexes `cattos`, `doggos` not found.",
"code": "index_not_found", "code": "index_not_found",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found" "link": "https://docs.meilisearch.com/errors#index_not_found"

View File

@ -339,7 +339,9 @@ pub enum Error {
MissingParameter(&'static str), MissingParameter(&'static str),
#[error("`actions` field value `{0}` is invalid. It should be an array of string representing action names.")] #[error("`actions` field value `{0}` is invalid. It should be an array of string representing action names.")]
InvalidApiKeyActions(Value), InvalidApiKeyActions(Value),
#[error("`indexes` field value `{0}` is invalid. It should be an array of string representing index names.")] #[error(
"`{0}` is not a valid index uid. It should be an array of string representing index names."
)]
InvalidApiKeyIndexes(Value), InvalidApiKeyIndexes(Value),
#[error("`expiresAt` field value `{0}` is invalid. It should follow the RFC 3339 format to represents a date or datetime in the future or specified as a null value. e.g. 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'.")] #[error("`expiresAt` field value `{0}` is invalid. It should follow the RFC 3339 format to represents a date or datetime in the future or specified as a null value. e.g. 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'.")]
InvalidApiKeyExpiresAt(Value), InvalidApiKeyExpiresAt(Value),