From 7b4b57ecc82563fbc842e1d1eee25b8a9468896b Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 8 Feb 2023 14:54:05 +0100 Subject: [PATCH] Fix the current tests --- dump/src/lib.rs | 7 +++---- meilisearch-types/src/index_uid_pattern.rs | 1 + meilisearch/tests/auth/api_keys.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dump/src/lib.rs b/dump/src/lib.rs index 7a7b9a5b7..8f7c28b8a 100644 --- a/dump/src/lib.rs +++ b/dump/src/lib.rs @@ -203,12 +203,11 @@ pub(crate) mod test { use big_s::S; use maplit::btreeset; - use meilisearch_types::index_uid::IndexUid; + use meilisearch_types::index_uid_pattern::IndexUidPattern; use meilisearch_types::keys::{Action, Key}; use meilisearch_types::milli::update::Setting; use meilisearch_types::milli::{self}; use meilisearch_types::settings::{Checked, Settings}; - use meilisearch_types::star_or::StarOr; use meilisearch_types::tasks::{Details, Status}; use serde_json::{json, Map, Value}; use time::macros::datetime; @@ -341,7 +340,7 @@ pub(crate) mod test { name: Some(S("doggos_key")), uid: Uuid::from_str("9f8a34da-b6b2-42f0-939b-dbd4c3448655").unwrap(), actions: vec![Action::DocumentsAll], - indexes: vec![StarOr::Other(IndexUid::from_str("doggos").unwrap())], + indexes: vec![IndexUidPattern::from_str("doggos").unwrap()], expires_at: Some(datetime!(4130-03-14 12:21 UTC)), created_at: datetime!(1960-11-15 0:00 UTC), updated_at: datetime!(2022-11-10 0:00 UTC), @@ -351,7 +350,7 @@ pub(crate) mod test { name: Some(S("master_key")), uid: Uuid::from_str("4622f717-1c00-47bb-a494-39d76a49b591").unwrap(), actions: vec![Action::All], - indexes: vec![StarOr::Star], + indexes: vec![IndexUidPattern::all()], expires_at: None, created_at: datetime!(0000-01-01 00:01 UTC), updated_at: datetime!(1964-05-04 17:25 UTC), diff --git a/meilisearch-types/src/index_uid_pattern.rs b/meilisearch-types/src/index_uid_pattern.rs index 88e0292f2..9f49c06ea 100644 --- a/meilisearch-types/src/index_uid_pattern.rs +++ b/meilisearch-types/src/index_uid_pattern.rs @@ -69,6 +69,7 @@ impl TryFrom for IndexUidPattern { fn try_from(uid: String) -> Result { let result = match uid.strip_suffix('*') { + Some("") => Ok(IndexUidPattern(uid)), Some(prefix) => IndexUid::from_str(prefix).map(|_| IndexUidPattern(uid)), None => IndexUid::try_from(uid).map(IndexUid::into_inner).map(IndexUidPattern), }; diff --git a/meilisearch/tests/auth/api_keys.rs b/meilisearch/tests/auth/api_keys.rs index 0a14107a8..abc0aea53 100644 --- a/meilisearch/tests/auth/api_keys.rs +++ b/meilisearch/tests/auth/api_keys.rs @@ -386,7 +386,7 @@ async fn error_add_api_key_invalid_index_uids() { meili_snap::snapshot!(code, @"400 Bad Request"); meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###" { - "message": "`invalid index # / \\name with spaces` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_). at `.indexes[0]`.", + "message": "`invalid index # / \\name with spaces` is not a valid index uid pattern. Index uid patterns can be an integer or a string containing only alphanumeric characters, hyphens (-), underscores (_), and optionally end with a star (*). at `.indexes[0]`.", "code": "invalid_api_key_indexes", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid-api-key-indexes"