From 66de69576dc0e240e087c940e171e7acc7ce861c Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Tue, 21 May 2024 09:17:43 +0100 Subject: [PATCH] test: show error when test env is not running --- tests/common/client.rs | 9 ++++++--- tests/environments/shared.rs | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/common/client.rs b/tests/common/client.rs index 1e938d1d..9312ac6f 100644 --- a/tests/common/client.rs +++ b/tests/common/client.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use reqwest::multipart; +use reqwest::{multipart, Error}; use serde::Serialize; use super::connection_info::ConnectionInfo; @@ -39,9 +39,12 @@ impl Client { } /// It checks if the server is running. - pub async fn server_is_running(&self) -> bool { + pub async fn server_is_running(&self) -> Result<(), Error> { let response = self.http_client.inner_get("").await; - response.is_ok() + match response { + Ok(_) => Ok(()), + Err(err) => Err(err), + } } // Context: about diff --git a/tests/environments/shared.rs b/tests/environments/shared.rs index d9db57be..30ad1193 100644 --- a/tests/environments/shared.rs +++ b/tests/environments/shared.rs @@ -16,8 +16,10 @@ impl TestEnv { pub async fn running() -> Self { let env = Self::default(); let client = Client::unauthenticated(&env.server_socket_addr().unwrap()); - let is_running = client.server_is_running().await; - assert!(is_running, "Test server is not running on {}", env.authority); + match client.server_is_running().await { + Ok(()) => {} + Err(err) => panic!("Test server is not running on {}. Error: {err}", env.authority), + } env }