test: Allow integration tests that should_panic to pass if TEST_INTEGRATION isn't set

pull/24376/head
Carol (Nichols || Goulding) 2023-01-12 15:31:34 -05:00
parent 02c7ed58a2
commit f56123bf30
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
2 changed files with 21 additions and 11 deletions

View File

@ -892,7 +892,10 @@ mod kafkaless_rpc_write {
#[should_panic(expected = "did not get additional Parquet files in the catalog")]
async fn never_persist_really_never_persists() {
test_helpers::maybe_start_logging();
let database_url = maybe_skip_integration!();
// Tell the test to panic with the expected message if `TEST_INTEGRATION` isn't set so that
// this still passes
let database_url =
maybe_skip_integration!("did not get additional Parquet files in the catalog");
let table_name = "the_table";

View File

@ -108,7 +108,7 @@ fn dump_log_to_stdout(server_type: &str, log_path: &std::path::Path) {
// variables are not set.
#[macro_export]
macro_rules! maybe_skip_integration {
() => {{
($panic_msg:expr) => {{
use std::env;
dotenvy::dotenv().ok();
@ -126,17 +126,24 @@ macro_rules! maybe_skip_integration {
would connect to a Postgres catalog."
)
}
(false, Some(_)) => {
eprintln!("skipping end-to-end integration tests - set TEST_INTEGRATION to run");
return;
}
(false, None) => {
eprintln!(
"skipping end-to-end integration tests - set TEST_INTEGRATION and \
TEST_INFLUXDB_IOX_CATALOG_DSN to run"
);
(false, maybe_dsn) => {
let unset_vars = match maybe_dsn {
Some(_) => "TEST_INTEGRATION",
None => "TEST_INTEGRATION and TEST_INFLUXDB_IOX_CATALOG_DSN",
};
eprintln!("skipping end-to-end integration tests - set {unset_vars} to run");
let panic_msg: &'static str = $panic_msg;
if !panic_msg.is_empty() {
panic!("{}", panic_msg);
}
return;
}
}
}};
() => {
maybe_skip_integration!("")
};
}