fix: updated_at was not 'updated' when updating the index name

This commit is contained in:
Tamo
2025-08-07 17:34:11 +02:00
parent ae2d0a67a4
commit ae5bd9d0e3
3 changed files with 43 additions and 6 deletions

View File

@ -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");
}