diff --git a/prqlc/prqlc/tests/integration/dbs/mod.rs b/prqlc/prqlc/tests/integration/dbs/mod.rs index e712b3e4780f..5c034d225ea6 100644 --- a/prqlc/prqlc/tests/integration/dbs/mod.rs +++ b/prqlc/prqlc/tests/integration/dbs/mod.rs @@ -75,7 +75,7 @@ impl DbConnection { }) } - pub fn setup(&mut self) { + pub fn setup(mut self) -> Self { let schema = include_str!("../data/chinook/schema.sql"); schema .split(';') @@ -92,6 +92,7 @@ impl DbConnection { let path = format!("{}/{}.csv", self.cfg.data_file_root, stem); self.runner.import_csv(&mut *self.protocol, &path, stem); } + self } // If it's supported, test unless it has `duckdb:skip`. If it's not diff --git a/prqlc/prqlc/tests/integration/queries.rs b/prqlc/prqlc/tests/integration/queries.rs index e5f295b4c06f..bb8d6712d79d 100644 --- a/prqlc/prqlc/tests/integration/queries.rs +++ b/prqlc/prqlc/tests/integration/queries.rs @@ -104,7 +104,7 @@ mod results { static CONNECTIONS: OnceLock>> = OnceLock::new(); CONNECTIONS.get_or_init(|| { Mutex::new({ - let configs = [ + [ ConnectionCfg { dialect: Dialect::SQLite, data_file_root: "tests/integration/data/chinook".to_string(), @@ -155,29 +155,20 @@ mod results { protocol: DbProtocol::MsSql, }, - ]; - - let mut connections = Vec::new(); - for cfg in configs { - if !matches!( + ] + .into_iter() + .filter(|cfg| { + matches!( cfg.dialect.support_level(), SupportLevel::Supported | SupportLevel::Unsupported - ) { - continue; - } - - // The filtering is not a great design, since it doesn't proactively - // check that we can get connections; but it's a compromise given we - // implement the external_dbs feature using this. - let Some(mut connection) = DbConnection::new(cfg) else { - continue; - }; - - connection.setup(); - - connections.push(connection); - } - connections + ) + }) + // The filtering is not a great design, since it doesn't proactively + // check that we can get connections; but it's a compromise given we + // implement the external_dbs feature using this. + .filter_map(DbConnection::new) + .map(|conn| conn.setup()) + .collect() }) }) }