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

Code before:
use crate::common::Server;

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

    assert_eq!(code, 202);

    index.wait_task(response.uid()).await;

    let (response, code) = index.get().await;

    assert_eq!(code, 200);
    assert!(response.get("createdAt").is_some());
    assert!(response.get("updatedAt").is_some());
    assert_eq!(response["createdAt"], response["updatedAt"]);
    assert_eq!(response["primaryKey"], Value::Null);
    assert_eq!(response.as_object().unwrap().len(), 4);
}

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

    let (response, code) = index.get().await;

    let expected_response = json!({
        "message": format!("Index `{}` not found.", index.uid),
        "code": "index_not_found",
        "type": "invalid_request",
        "link": "https://docs.meilisearch.com/errors#index_not_found"
    });

    assert_eq!(response, expected_response);
    assert_eq!(code, 404);
}

#[actix_rt::test]
async fn no_index_return_empty_list() {
    let server = Server::new().await;
    let (response, code) = server.list_indexes(None, None).await;
    assert_eq!(code, 200);
    assert!(response["results"].is_array());
    assert!(response["results"].as_array().unwrap().is_empty());
}

#[actix_rt::test]
async fn list_multiple_indexes() {

Review comment (suggestion):
I believe you can directly use the special [`shared_does_not_exists_index`](https://github.com/meilisearch/meilisearch/blob/8f006eeaf3c001a0fe72a43772bfb871e588debf/crates/meilisearch/tests/common/mod.rs#L163C14-L169) here 

```suggestion
    let index = shared_does_not_exists_index();
```

Code after:
use crate::common::{shared_does_not_exists_index, Server};

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

    assert_eq!(code, 202);

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

    let (response, code) = index.get().await;

    assert_eq!(code, 200);
    assert!(response.get("createdAt").is_some());
    assert!(response.get("updatedAt").is_some());
    assert_eq!(response["createdAt"], response["updatedAt"]);
    assert_eq!(response["primaryKey"], Value::Null);
    assert_eq!(response.as_object().unwrap().len(), 4);
}

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

    let (response, code) = index.get().await;

    let expected_response = json!({
        "message": "Index `DOES_NOT_EXISTS` not found.",
        "code": "index_not_found",
        "type": "invalid_request",
        "link": "https://docs.meilisearch.com/errors#index_not_found"
    });

    assert_eq!(response, expected_response);
    assert_eq!(code, 404);
}

#[actix_rt::test]
async fn no_index_return_empty_list() {
    let server = Server::new().await;
    let (response, code) = server.list_indexes(None, None).await;
    assert_eq!(code, 200);
    assert!(response["results"].is_array());
    assert!(response["results"].as_array().unwrap().is_empty());
}

#[actix_rt::test]
async fn list_multiple_indexes() {
    let server = Server::new().await;