mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 00:31:02 +00:00
index UID format; fix #497
This commit is contained in:
committed by
Quentin de Quelen
parent
041eed2a06
commit
c5b6e641a4
@ -14,6 +14,8 @@ fn delete() {
|
||||
assert_eq!(status_code, 404);
|
||||
}
|
||||
|
||||
|
||||
// Resolve teh issue https://github.com/meilisearch/MeiliSearch/issues/493
|
||||
#[test]
|
||||
fn delete_batch() {
|
||||
let mut server = common::Server::with_uid("movies");
|
||||
|
@ -470,8 +470,10 @@ fn create_index_failed() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Resolve issue https://github.com/meilisearch/MeiliSearch/issues/492
|
||||
#[test]
|
||||
fn create_index_with_identifier() {
|
||||
fn create_index_with_identifier_and_index() {
|
||||
let mut server = common::Server::with_uid("movies");
|
||||
|
||||
let body = json!({
|
||||
@ -498,3 +500,53 @@ fn create_index_with_identifier() {
|
||||
|
||||
assert_json_eq!(response, expect, ordered: false);
|
||||
}
|
||||
|
||||
// Resolve issue https://github.com/meilisearch/MeiliSearch/issues/497
|
||||
#[test]
|
||||
fn create_index_with_invalid_uid() {
|
||||
let mut server = common::Server::with_uid("");
|
||||
|
||||
let body = json!({
|
||||
"uid": "the movies"
|
||||
});
|
||||
|
||||
let (response, status_code) = server.create_index(body);
|
||||
assert_eq!(status_code, 400);
|
||||
|
||||
let message = response["message"].as_str().unwrap();
|
||||
assert_eq!(response.as_object().unwrap().len(), 1);
|
||||
assert_eq!(message, "Index must have a valid uid; Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_).");
|
||||
|
||||
let body = json!({
|
||||
"uid": "%$#"
|
||||
});
|
||||
|
||||
let (response, status_code) = server.create_index(body);
|
||||
assert_eq!(status_code, 400);
|
||||
|
||||
let message = response["message"].as_str().unwrap();
|
||||
assert_eq!(response.as_object().unwrap().len(), 1);
|
||||
assert_eq!(message, "Index must have a valid uid; Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_).");
|
||||
|
||||
let body = json!({
|
||||
"uid": "the~movies"
|
||||
});
|
||||
|
||||
let (response, status_code) = server.create_index(body);
|
||||
assert_eq!(status_code, 400);
|
||||
|
||||
let message = response["message"].as_str().unwrap();
|
||||
assert_eq!(response.as_object().unwrap().len(), 1);
|
||||
assert_eq!(message, "Index must have a valid uid; Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_).");
|
||||
|
||||
let body = json!({
|
||||
"uid": "🎉"
|
||||
});
|
||||
|
||||
let (response, status_code) = server.create_index(body);
|
||||
assert_eq!(status_code, 400);
|
||||
|
||||
let message = response["message"].as_str().unwrap();
|
||||
assert_eq!(response.as_object().unwrap().len(), 1);
|
||||
assert_eq!(message, "Index must have a valid uid; Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_).");
|
||||
}
|
||||
|
Reference in New Issue
Block a user