mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +02:00
restructure project
This commit is contained in:
parent
8061a04661
commit
5ecf514d28
75 changed files with 4377 additions and 323 deletions
64
meilisearch-http/tests/index/update_index.rs
Normal file
64
meilisearch-http/tests/index/update_index.rs
Normal file
|
@ -0,0 +1,64 @@
|
|||
use crate::common::Server;
|
||||
use chrono::DateTime;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn update_primary_key() {
|
||||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
let (_, code) = index.create(None).await;
|
||||
|
||||
assert_eq!(code, 200);
|
||||
|
||||
let (response, code) = index.update(Some("primary")).await;
|
||||
|
||||
assert_eq!(code, 200);
|
||||
assert_eq!(response["uid"], "test");
|
||||
assert!(response.get("uuid").is_some());
|
||||
assert!(response.get("createdAt").is_some());
|
||||
assert!(response.get("updatedAt").is_some());
|
||||
|
||||
let created_at = DateTime::parse_from_rfc3339(response["createdAt"].as_str().unwrap()).unwrap();
|
||||
let updated_at = DateTime::parse_from_rfc3339(response["updatedAt"].as_str().unwrap()).unwrap();
|
||||
assert!(created_at < updated_at);
|
||||
|
||||
assert_eq!(response["primaryKey"], "primary");
|
||||
assert_eq!(response.as_object().unwrap().len(), 5);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn update_nothing() {
|
||||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
let (response, code) = index.create(None).await;
|
||||
|
||||
assert_eq!(code, 200);
|
||||
|
||||
let (update, code) = index.update(None).await;
|
||||
|
||||
assert_eq!(code, 200);
|
||||
assert_eq!(response, update);
|
||||
}
|
||||
|
||||
// TODO: partial test since we are testing error, amd error is not yet fully implemented in
|
||||
// transplant
|
||||
#[actix_rt::test]
|
||||
async fn update_existing_primary_key() {
|
||||
let server = Server::new().await;
|
||||
let index = server.index("test");
|
||||
let (_response, code) = index.create(Some("primary")).await;
|
||||
|
||||
assert_eq!(code, 200);
|
||||
|
||||
let (_update, code) = index.update(Some("primary2")).await;
|
||||
|
||||
assert_eq!(code, 400);
|
||||
}
|
||||
|
||||
// TODO: partial test since we are testing error, amd error is not yet fully implemented in
|
||||
// transplant
|
||||
#[actix_rt::test]
|
||||
async fn test_unexisting_index() {
|
||||
let server = Server::new().await;
|
||||
let (_response, code) = server.index("test").update(None).await;
|
||||
assert_eq!(code, 400);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue