Repository: meilisearch/meilisearch
File: crates/meilisearch/tests/index/update_index.rs (Rust)

Code before:

    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);

    assert_eq!(response["primaryKey"], "primary");
    assert_eq!(response.as_object().unwrap().len(), 4);
}

#[actix_rt::test]
async fn create_and_update_with_different_encoding() {
    let server = Server::new_shared();
    let index = server.unique_index_with_encoder(Encoder::Gzip);
    let (create_task, code) = index.create(None).await;

    assert_eq!(code, 202);
    index.wait_task(create_task.uid()).await.succeeded();

    let index = index.with_encoder(Encoder::Brotli);
    let (task, _status_code) = index.update(Some("primary")).await;

    let response = index.wait_task(task.uid()).await.succeeded();

    assert_eq!(response["status"], "succeeded");
}

#[actix_rt::test]
async fn update_nothing() {
    let server = Server::new_shared();
    let index = server.unique_index();
    let (task1, code) = index.create(None).await;

    assert_eq!(code, 202);

    index.wait_task(task1.uid()).await.succeeded();

    let (task2, code) = index.update(None).await;

    assert_eq!(code, 202);

    let response = index.wait_task(task2.uid()).await.succeeded();

    assert_eq!(response["status"], "succeeded");
}

#[actix_rt::test]
async fn error_update_existing_primary_key() {
    let server = Server::new_shared();
    let index = server.unique_index();

Review comment (suggestion):
```suggestion
    index.wait_task(task.uid()).await.succeeded();
```

Same

Code after:
    let updated_at =
        OffsetDateTime::parse(response["updatedAt"].as_str().unwrap(), &Rfc3339).unwrap();
    assert!(created_at < updated_at);

    assert_eq!(response["primaryKey"], "primary");
    assert_eq!(response.as_object().unwrap().len(), 4);
}

#[actix_rt::test]
async fn create_and_update_with_different_encoding() {
    let server = Server::new_shared();
    let index = server.unique_index_with_encoder(Encoder::Gzip);
    let (create_task, code) = index.create(None).await;

    assert_eq!(code, 202);
    index.wait_task(create_task.uid()).await.succeeded();

    let index = index.with_encoder(Encoder::Brotli);
    let (task, _status_code) = index.update(Some("primary")).await;

    index.wait_task(task.uid()).await.succeeded();
}

#[actix_rt::test]
async fn update_nothing() {
    let server = Server::new_shared();
    let index = server.unique_index();
    let (task1, code) = index.create(None).await;

    assert_eq!(code, 202);

    index.wait_task(task1.uid()).await.succeeded();

    let (task2, code) = index.update(None).await;

    assert_eq!(code, 202);

    index.wait_task(task2.uid()).await.succeeded();
}

#[actix_rt::test]
async fn error_update_existing_primary_key() {
    let index = shared_index_with_documents().await;

    let (update_task, code) = index.update_index_fail(Some("primary")).await;

    assert_eq!(code, 202);
    let response = index.wait_task(update_task.uid()).await.failed();

    let expected_response = json!({
        "message": format!("Index `{}`: Index already has a primary key: `id`.", index.uid),