From 10b39e1ff4f234ef44a581af3d30522314a3ac72 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Mon, 18 Nov 2024 16:10:56 +0100 Subject: [PATCH] chore(cubesql): E2E - check that env variables are not empty --- rust/cubesql/cubesql/e2e/tests/postgres.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/rust/cubesql/cubesql/e2e/tests/postgres.rs b/rust/cubesql/cubesql/e2e/tests/postgres.rs index d0ed86409bef8..87d17d48a6069 100644 --- a/rust/cubesql/cubesql/e2e/tests/postgres.rs +++ b/rust/cubesql/cubesql/e2e/tests/postgres.rs @@ -25,17 +25,32 @@ pub struct PostgresIntegrationTestSuite { // connection: tokio_postgres::Connection, } +fn get_env_var(env_name: &'static str) -> Option { + if let Ok(value) = env::var(env_name) { + // Variable can be defined, but be empty on the CI + if value.is_empty() { + log::warn!("Environment variable {} is declared, but empty", env_name); + + None + } else { + Some(value) + } + } else { + None + } +} + impl PostgresIntegrationTestSuite { pub(crate) async fn before_all() -> AsyncTestConstructorResult { let mut env_defined = false; - if let Ok(testing_cube_token) = env::var("CUBESQL_TESTING_CUBE_TOKEN".to_string()) { + if let Some(testing_cube_token) = get_env_var("CUBESQL_TESTING_CUBE_TOKEN") { env::set_var("CUBESQL_CUBE_TOKEN", testing_cube_token); env_defined = true; }; - if let Ok(testing_cube_url) = env::var("CUBESQL_TESTING_CUBE_URL".to_string()) { + if let Some(testing_cube_url) = get_env_var("CUBESQL_TESTING_CUBE_URL") { env::set_var("CUBESQL_CUBE_URL", testing_cube_url); } else { env_defined = false;