Compare commits

..

1 Commits

Author SHA1 Message Date
Alexander Zaitsev
380197c901
Merge f8b7a48b1a57df51b48eee6a6fea798952c00df2 into 022205af9024d8cde22dcdd29c1722f81f77ab0b 2025-01-24 14:07:39 +01:00
3 changed files with 16 additions and 34 deletions

View File

@ -371,7 +371,8 @@ VectorEmbeddingError , InvalidRequest , BAD_REQUEST ;
NotFoundSimilarId , InvalidRequest , BAD_REQUEST ;
InvalidDocumentEditionContext , InvalidRequest , BAD_REQUEST ;
InvalidDocumentEditionFunctionFilter , InvalidRequest , BAD_REQUEST ;
EditDocumentsByFunctionError , InvalidRequest , BAD_REQUEST
EditDocumentsByFunctionError , InvalidRequest , BAD_REQUEST ;
CouldNotUpgrade , InvalidRequest , BAD_REQUEST
}
impl ErrorCode for JoinError {

View File

@ -222,26 +222,6 @@ impl Server<Shared> {
(value, code)
}
pub async fn list_indexes(
&self,
offset: Option<usize>,
limit: Option<usize>,
) -> (Value, StatusCode) {
let (offset, limit) = (
offset.map(|offset| format!("offset={offset}")),
limit.map(|limit| format!("limit={limit}")),
);
let query_parameter = offset
.as_ref()
.zip(limit.as_ref())
.map(|(offset, limit)| format!("{offset}&{limit}"))
.or_else(|| offset.xor(limit));
if let Some(query_parameter) = query_parameter {
self.service.get(format!("/indexes?{query_parameter}")).await
} else {
self.service.get("/indexes").await
}
}
pub async fn update_raw_index_fail(
&self,
uid: impl AsRef<str>,

View File

@ -1,22 +1,22 @@
use crate::json;
use meili_snap::{json_string, snapshot};
use serde_json::Value;
use serde_json::{json, Value};
use crate::common::{shared_does_not_exists_index, Server};
use crate::common::Server;
#[actix_rt::test]
async fn create_and_get_index() {
let server = Server::new_shared();
let index = server.unique_index();
let (response, code) = index.create(None).await;
let server = Server::new().await;
let index = server.index("test");
let (task, code) = index.create(None).await;
assert_eq!(code, 202);
index.wait_task(response.uid()).await.succeeded();
index.wait_task(task.uid()).await.succeeded();
let (response, code) = index.get().await;
assert_eq!(code, 200);
assert_eq!(response["uid"], "test");
assert!(response.get("createdAt").is_some());
assert!(response.get("updatedAt").is_some());
assert_eq!(response["createdAt"], response["updatedAt"]);
@ -26,12 +26,13 @@ async fn create_and_get_index() {
#[actix_rt::test]
async fn error_get_unexisting_index() {
let index = shared_does_not_exists_index().await;
let server = Server::new().await;
let index = server.index("test");
let (response, code) = index.get().await;
let expected_response = json!({
"message": "Index `DOES_NOT_EXISTS` not found.",
"message": "Index `test` not found.",
"code": "index_not_found",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#index_not_found"
@ -178,14 +179,14 @@ async fn get_and_paginate_indexes() {
#[actix_rt::test]
async fn get_invalid_index_uid() {
let server = Server::new_shared();
let (response, code) =
server.create_index_fail(json!({ "uid": "this is not a valid index name" })).await;
let server = Server::new().await;
let index = server.index("this is not a valid index name");
let (response, code) = index.get().await;
snapshot!(code, @"400 Bad Request");
snapshot!(json_string!(response), @r###"
{
"message": "Invalid value at `.uid`: `this is not a valid index name` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_), and can not be more than 512 bytes.",
"message": "`this is not a valid index name` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_), and can not be more than 512 bytes.",
"code": "invalid_index_uid",
"type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#invalid_index_uid"