Skip to content

Commit

Permalink
test: show error when test env is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed May 21, 2024
1 parent 757751f commit 66de695
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions tests/common/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Duration;

use reqwest::multipart;
use reqwest::{multipart, Error};
use serde::Serialize;

use super::connection_info::ConnectionInfo;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/environments/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 66de695

Please sign in to comment.