mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 18:45:06 +08:00
a30e02c18c
implements: https://github.com/meilisearch/specifications/blob/develop/text/0060-refashion-updates-apis.md linked PR: - #1889 - #1891 - #1892 - #1902 - #1906 - #1911 - #1914 - #1915 - #1916 - #1918 - #1924 - #1925 - #1926 - #1930 - #1936 - #1937 - #1942 - #1944 - #1945 - #1946 - #1947 - #1950 - #1951 - #1957 - #1959 - #1960 - #1961 - #1962 - #1964 - https://github.com/meilisearch/milli/pull/414 - https://github.com/meilisearch/milli/pull/409 - https://github.com/meilisearch/milli/pull/406 - https://github.com/meilisearch/milli/pull/418 - close #1687 - close #1786 - close #1940 - close #1948 - close #1949 - close #1932 - close #1956
71 lines
2.1 KiB
Rust
71 lines
2.1 KiB
Rust
use serde_json::json;
|
|
|
|
use crate::common::Server;
|
|
|
|
#[actix_rt::test]
|
|
async fn get_settings_unexisting_index() {
|
|
let server = Server::new().await;
|
|
let (response, code) = server.version().await;
|
|
assert_eq!(code, 200);
|
|
let version = response.as_object().unwrap();
|
|
assert!(version.get("commitSha").is_some());
|
|
assert!(version.get("commitDate").is_some());
|
|
assert!(version.get("pkgVersion").is_some());
|
|
}
|
|
|
|
#[actix_rt::test]
|
|
async fn test_healthyness() {
|
|
let server = Server::new().await;
|
|
|
|
let (response, status_code) = server.service.get("/health").await;
|
|
assert_eq!(status_code, 200);
|
|
assert_eq!(response["status"], "available");
|
|
}
|
|
|
|
#[actix_rt::test]
|
|
async fn stats() {
|
|
let server = Server::new().await;
|
|
let index = server.index("test");
|
|
let (_, code) = index.create(Some("id")).await;
|
|
|
|
assert_eq!(code, 202);
|
|
index.wait_task(0).await;
|
|
|
|
let (response, code) = server.stats().await;
|
|
|
|
assert_eq!(code, 200);
|
|
assert!(response.get("databaseSize").is_some());
|
|
assert!(response.get("lastUpdate").is_some());
|
|
assert!(response["indexes"].get("test").is_some());
|
|
assert_eq!(response["indexes"]["test"]["numberOfDocuments"], 0);
|
|
assert!(response["indexes"]["test"]["isIndexing"] == false);
|
|
|
|
let documents = json!([
|
|
{
|
|
"id": 1,
|
|
"name": "Alexey",
|
|
},
|
|
{
|
|
"id": 2,
|
|
"age": 45,
|
|
}
|
|
]);
|
|
|
|
let (response, code) = index.add_documents(documents, None).await;
|
|
assert_eq!(code, 202, "{}", response);
|
|
assert_eq!(response["uid"], 1);
|
|
|
|
index.wait_task(1).await;
|
|
|
|
let (response, code) = server.stats().await;
|
|
|
|
assert_eq!(code, 200);
|
|
assert!(response["databaseSize"].as_u64().unwrap() > 0);
|
|
assert!(response.get("lastUpdate").is_some());
|
|
assert_eq!(response["indexes"]["test"]["numberOfDocuments"], 2);
|
|
assert!(response["indexes"]["test"]["isIndexing"] == false);
|
|
assert_eq!(response["indexes"]["test"]["fieldDistribution"]["id"], 2);
|
|
assert_eq!(response["indexes"]["test"]["fieldDistribution"]["name"], 1);
|
|
assert_eq!(response["indexes"]["test"]["fieldDistribution"]["age"], 1);
|
|
}
|