refactor: convert `run_table_names_test_case` to a function
@@ -9,11 +9,13 @@ use crate::scenarios::*;
/// runs table_names(predicate) and compares it to the expected
/// output
-macro_rules! run_table_names_test_case {
- ($DB_SETUP:expr, $PREDICATE:expr, $EXPECTED_NAMES:expr) => {
+async fn run_table_names_test_case<D>(db_setup: D, predicate: Predicate, expected_names: Vec<&str>)
+where
+ D: DbSetup,
+{
test_helpers::maybe_start_logging();
- let predicate = $PREDICATE;
- for scenario in $DB_SETUP.make().await {
+
+ for scenario in db_setup.make().await {
let DbScenario {
scenario_name, db, ..
} = scenario;
@@ -30,7 +32,6 @@ macro_rules! run_table_names_test_case {
.await
.expect("converted plan to strings successfully");
- let expected_names = $EXPECTED_NAMES;
assert_eq!(
names,
to_stringset(&expected_names),
@@ -40,37 +41,36 @@ macro_rules! run_table_names_test_case {
names
);
}
- };
}
#[tokio::test]
async fn list_table_names_no_data_no_pred() {
- run_table_names_test_case!(NoData {}, EMPTY_PREDICATE, vec![]);
+ run_table_names_test_case(NoData {}, EMPTY_PREDICATE, vec![]).await;
}
#[tokio::test]
async fn list_table_names_no_data_pred() {
- run_table_names_test_case!(TwoMeasurements {}, EMPTY_PREDICATE, vec!["cpu", "disk"]);
+ run_table_names_test_case(TwoMeasurements {}, EMPTY_PREDICATE, vec!["cpu", "disk"]).await;
}
#[tokio::test]
async fn list_table_names_data_pred_0_201() {
- run_table_names_test_case!(TwoMeasurements {}, tsp(0, 201), vec!["cpu", "disk"]);
+ run_table_names_test_case(TwoMeasurements {}, tsp(0, 201), vec!["cpu", "disk"]).await;
}
#[tokio::test]
async fn list_table_names_data_pred_0_200() {
- run_table_names_test_case!(TwoMeasurements {}, tsp(0, 200), vec!["cpu"]);
+ run_table_names_test_case(TwoMeasurements {}, tsp(0, 200), vec!["cpu"]).await;
}
#[tokio::test]
async fn list_table_names_data_pred_50_101() {
- run_table_names_test_case!(TwoMeasurements {}, tsp(50, 101), vec!["cpu"]);
+ run_table_names_test_case(TwoMeasurements {}, tsp(50, 101), vec!["cpu"]).await;
}
#[tokio::test]
async fn list_table_names_data_pred_250_300() {
- run_table_names_test_case!(TwoMeasurements {}, tsp(250, 300), vec![]);
+ run_table_names_test_case(TwoMeasurements {}, tsp(250, 300), vec![]).await;
}
// make a single timestamp predicate between r1 and r2
