Skip to content

Commit b75a37a

Browse files
authored
chore(cubesql): E2E - check that env variables are not empty (#8965)
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.
1 parent b103af8 commit b75a37a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

rust/cubesql/cubesql/e2e/tests/postgres.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,32 @@ pub struct PostgresIntegrationTestSuite {
2525
// connection: tokio_postgres::Connection<Socket, NoTlsStream>,
2626
}
2727

28+
fn get_env_var(env_name: &'static str) -> Option<String> {
29+
if let Ok(value) = env::var(env_name) {
30+
// Variable can be defined, but be empty on the CI
31+
if value.is_empty() {
32+
log::warn!("Environment variable {} is declared, but empty", env_name);
33+
34+
None
35+
} else {
36+
Some(value)
37+
}
38+
} else {
39+
None
40+
}
41+
}
42+
2843
impl PostgresIntegrationTestSuite {
2944
pub(crate) async fn before_all() -> AsyncTestConstructorResult {
3045
let mut env_defined = false;
3146

32-
if let Ok(testing_cube_token) = env::var("CUBESQL_TESTING_CUBE_TOKEN".to_string()) {
47+
if let Some(testing_cube_token) = get_env_var("CUBESQL_TESTING_CUBE_TOKEN") {
3348
env::set_var("CUBESQL_CUBE_TOKEN", testing_cube_token);
3449

3550
env_defined = true;
3651
};
3752

38-
if let Ok(testing_cube_url) = env::var("CUBESQL_TESTING_CUBE_URL".to_string()) {
53+
if let Some(testing_cube_url) = get_env_var("CUBESQL_TESTING_CUBE_URL") {
3954
env::set_var("CUBESQL_CUBE_URL", testing_cube_url);
4055
} else {
4156
env_defined = false;

0 commit comments

Comments
 (0)