0

This is an example of the integration test I am trying to write. It fails with "cannot start a runtime within a runtime" because #[tokio::test] creates a runtime to run the test and then the application tries to create another runtime inside it.

I could use a blocking HTTP library like ureq but I would like to avoid introducing another dependency.

#[tokio::test]
async fn test_integration() -> Result<()> {
    let app_manager = AppManager::new(); // Uses tokio::runtime::Builder::new_multi_thread() internally

    let client = hyper::Client::new();
    let uri = hyper::Uri::from_static("http://localhost:8080/test");
    let response = client.get(uri).await?;

    // do something with the response

    Ok(()) // pass the test
}
cactus
  • 197
  • 1
  • 12

0 Answers0