#[cfg(feature = "rustls-tls")]
async fn setup() -> soph_core::Result<()> {
    use soph_core::support::Container;
    let mut container = Container::default();

    container.register::<crate::Http>().await?;

    Ok(container.boot().await?)
}

#[cfg(feature = "rustls-tls")]
#[tokio::test]
async fn reqwest() -> crate::HttpResult<()> {
    let text = reqwest::get("https://www.rust-lang.org").await?.text().await?;

    assert!(text.contains("Rust"));

    Ok(())
}

#[cfg(feature = "rustls-tls")]
#[tokio::test]
async fn get() -> crate::HttpResult<()> {
    use crate::{error::Error, Http};
    use soph_core::{support::app, traits::ErrorTrait};

    setup().await?;

    let http = app().resolve::<Http>().map_err(Error::wrap)?;

    let text = http.get("https://www.rust-lang.org").send().await?.text().await?;

    assert!(text.contains("Rust"));

    Ok(())
}
