Repository: meilisearch/meilisearch
File: meilisearch/tests/tasks/mod.rs (Rust)

Code before:

    let (result, code) = server.create_index(json!({ "uid": "doggo" })).await;
    snapshot!(code, @"422 Unprocessable Entity");
    snapshot!(json_string!(result), @r###"
    {
      "message": "Meilisearch cannot receive write operations because the limit of the task database has been reached. Please delete tasks to continue performing write operations.",
      "code": "no_space_left_on_device",
      "type": "system",
      "link": "https://docs.meilisearch.com/errors#no_space_left_on_device"
    }
    "###);

    // But we should still be able to register tasks deletion IF they delete something
    let (result, code) = server.delete_tasks("uids=*").await;
    snapshot!(code, @"200 OK");
    snapshot!(json_string!(result, { ".enqueuedAt" => "[date]", ".taskUid" => "uid" }), @r###"
    {
      "taskUid": "uid",
      "indexUid": null,
      "status": "enqueued",
      "type": "taskDeletion",
      "enqueuedAt": "[date]"
    }
    "###);

    // But we should still be able to register tasks deletion IF they delete something
    let (result, code) = server.create_index(json!({ "uid": "doggo" })).await;
    snapshot!(code, @"202 Accepted");
    snapshot!(json_string!(result, { ".enqueuedAt" => "[date]", ".taskUid" => "uid" }), @r###"
    {
      "taskUid": "uid",
      "indexUid": "doggo",
      "status": "enqueued",
      "type": "indexCreation",
      "enqueuedAt": "[date]"
    }
    "###);

    // we're going to fill up the queue once again
    loop {
        let (res, code) = server.delete_tasks("uids=0").await;
        if code == 422 {
            break;
        }
        if res["taskUid"] == json!(null) {
            panic!(
                "Encountered the strange case:\n{}",
                serde_json::to_string_pretty(&res).unwrap()
            );
        }
    }

Review comment (suggestion):
```suggestion
    // Now we should be able to register tasks again
```

Code after:

    let (result, code) = server.create_index(json!({ "uid": "doggo" })).await;
    snapshot!(code, @"422 Unprocessable Entity");
    snapshot!(json_string!(result), @r###"
    {
      "message": "Meilisearch cannot receive write operations because the limit of the task database has been reached. Please delete tasks to continue performing write operations.",
      "code": "no_space_left_on_device",
      "type": "system",
      "link": "https://docs.meilisearch.com/errors#no_space_left_on_device"
    }
    "###);

    // But we should still be able to register tasks deletion IF they delete something
    let (result, code) = server.delete_tasks("uids=*").await;
    snapshot!(code, @"200 OK");
    snapshot!(json_string!(result, { ".enqueuedAt" => "[date]", ".taskUid" => "uid" }), @r###"
    {
      "taskUid": "uid",
      "indexUid": null,
      "status": "enqueued",
      "type": "taskDeletion",
      "enqueuedAt": "[date]"
    }
    "###);

    let result = server.wait_task(result["taskUid"].as_u64().unwrap()).await;
    snapshot!(json_string!(result["status"]), @r###""succeeded""###);

    // Now we should be able to register tasks again
    let (result, code) = server.create_index(json!({ "uid": "doggo" })).await;
    snapshot!(code, @"202 Accepted");
    snapshot!(json_string!(result, { ".enqueuedAt" => "[date]", ".taskUid" => "uid" }), @r###"
    {
      "taskUid": "uid",
      "indexUid": "doggo",
      "status": "enqueued",
      "type": "indexCreation",
      "enqueuedAt": "[date]"
    }
    "###);

    // we're going to fill up the queue once again
    loop {
        let (res, code) = server.delete_tasks("uids=0").await;
        if code == 422 {
            break;
        }
        if res["taskUid"] == json!(null) {
            panic!(
                "Encountered the strange case:\n{}",
                serde_json::to_string_pretty(&res).unwrap()