get method of the reqwest crate not working

pub struct TestApp {
    pub address: String,
    pub pool: PgPool,

async fn spawn_app() -> TestApp {
    let listener = TcpListener::bind("").expect("failed to bind to the port");
    let port = listener.local_addr().unwrap().port();
    let address = format!("{}", port);

    let configuration = get_configuration().expect("failed to read configuration");
    let connection_pool = PgPool::connect(&configuration.database.connection_string()).await.expect("failed to connect to postgres");
    let server = run(listener, connection_pool.clone()).expect("failed to bind to address");
    let _ = tokio::spawn(server);
        pool: connection_pool,

I am following the zero to production book.
This test function used to work before and now i run cargo test i get the following error.

async fn health_check_works() {
    let app = spawn_app().await;
    let client = reqwest::Client::new();
    let response = client
        .expect("Failed to execute request.");
    assert_eq!(Some(0), response.content_length());
thread 'health_check_works' panicked at 'Failed to execute request.: reqwest::Error { kind: Builder, source: RelativeUrlWithoutBase }', tests/

What is the issue and how do i solve it?

>Solution :

The URL must start with a protocol (http:// or https://):


Leave a Reply