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

Code before:
        "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_shared();
    let index1 = server.unique_index();
    let index2 = server.unique_index();

    let (task1, _) = index1.create(None).await;
    let (_task2, _) = index2.create(Some("key")).await;

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

    let (response, code) = server.list_indexes(None, None).await;
    dbg!(response.clone());
    assert_eq!(code, 200);
    assert!(response["results"].is_array());
    let arr = response["results"].as_array().unwrap();
    assert!(arr.len() >= 2);
    assert!(arr
        .iter()
        .any(|entry| entry["uid"] == index1.uid && entry["primaryKey"] == Value::Null));
    assert!(arr.iter().any(|entry| entry["uid"] == index2.uid && entry["primaryKey"] == "key"));
}

#[actix_rt::test]
async fn get_and_paginate_indexes() {
    let server = Server::new().await;
    const NB_INDEXES: usize = 50;
    for i in 0..NB_INDEXES {
        server.index(&format!("test_{i:02}")).create(None).await;
        server.index(&format!("test_{i:02}")).wait_task(i as u64).await;
    }

    // basic
    let (response, code) = server.list_indexes(None, None).await;
    assert_eq!(code, 200);

Review comment (bug):
The `wait_task(1)` was referring to the second task :sweat_smile: 
That's also what was causing your task queue corruption I believe (+ the fact we had a bug on main)

```suggestion
    index1.wait_task(task2.uid()).await.succeeded();
```

Code after:
    });

    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;
    server.index("test").create(None).await;
    let (task, _status_code) = server.index("test1").create(Some("key")).await;

    server.index("test").wait_task(task.uid()).await.succeeded();

    let (response, code) = server.list_indexes(None, None).await;
    assert_eq!(code, 200);
    assert!(response["results"].is_array());
    let arr = response["results"].as_array().unwrap();
    assert_eq!(arr.len(), 2);
    assert!(arr.iter().any(|entry| entry["uid"] == "test" && entry["primaryKey"] == Value::Null));
    assert!(arr.iter().any(|entry| entry["uid"] == "test1" && entry["primaryKey"] == "key"));
}

#[actix_rt::test]
async fn get_and_paginate_indexes() {
    let server = Server::new().await;
    const NB_INDEXES: usize = 50;
    for i in 0..NB_INDEXES {
        server.index(format!("test_{i:02}")).create(None).await;
        server.index(format!("test_{i:02}")).wait_task(i as u64).await;
    }

    // basic
    let (response, code) = server.list_indexes(None, None).await;
    assert_eq!(code, 200);
    assert_eq!(response["limit"], json!(20));
    assert_eq!(response["offset"], json!(0));
    assert_eq!(response["total"], json!(NB_INDEXES));
    assert!(response["results"].is_array());
    let arr = response["results"].as_array().unwrap();
    assert_eq!(arr.len(), 20);
    // ensuring we get all the indexes in the alphabetical order