mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-06 04:36:32 +00:00
fix: updated_at was not 'updated' when updating the index name
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
use meili_snap::snapshot;
|
||||
|
||||
use time::format_description::well_known::Rfc3339;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
@ -106,3 +108,34 @@ async fn error_update_unexisting_index() {
|
||||
|
||||
assert_eq!(response["error"], expected_response);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn update_index_name() {
|
||||
let server = Server::new_shared();
|
||||
let index = server.unique_index();
|
||||
let (task, code) = index.create(None).await;
|
||||
|
||||
assert_eq!(code, 202);
|
||||
server.wait_task(task.uid()).await.succeeded();
|
||||
|
||||
let new_index = server.unique_index();
|
||||
let (task, _status_code) = index.update_raw(json!({ "uid": new_index.uid })).await;
|
||||
server.wait_task(task.uid()).await.succeeded();
|
||||
|
||||
let (response, code) = new_index.get().await;
|
||||
|
||||
snapshot!(code, @"200 OK");
|
||||
|
||||
assert_eq!(response["uid"], new_index.uid);
|
||||
assert!(response.get("createdAt").is_some());
|
||||
assert!(response.get("updatedAt").is_some());
|
||||
|
||||
let created_at =
|
||||
OffsetDateTime::parse(response["createdAt"].as_str().unwrap(), &Rfc3339).unwrap();
|
||||
let updated_at =
|
||||
OffsetDateTime::parse(response["updatedAt"].as_str().unwrap(), &Rfc3339).unwrap();
|
||||
assert!(created_at < updated_at, "{created_at} should be inferior to {updated_at}");
|
||||
|
||||
snapshot!(response["primaryKey"], @"null");
|
||||
snapshot!(response.as_object().unwrap().len(), @"4");
|
||||
}
|
||||
|
Reference in New Issue
Block a user