Skip to content

Commit

Permalink
chore(cubesql): E2E - check that env variables are not empty (#8965)
Browse files Browse the repository at this point in the history
I figured out that CI is broken for contributors. I am not sure, but I believe it's related to the fact that environment variables are defined while being empty due to security restrictions for CI's variables.
  • Loading branch information
ovr authored Nov 18, 2024
1 parent b103af8 commit b75a37a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions rust/cubesql/cubesql/e2e/tests/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,32 @@ pub struct PostgresIntegrationTestSuite {
// connection: tokio_postgres::Connection<Socket, NoTlsStream>,
}

fn get_env_var(env_name: &'static str) -> Option<String> {
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;
Expand Down

0 comments on commit b75a37a

Please sign in to comment.