#![allow(unused)]
use microrm::prelude::*;
pub fn open_test_helper<S: Schema>(identifier: &'static str) -> (microrm::ConnectionPool, S) {
let path = test_db_path(identifier);
log::info!("path to test database: {path:?}");
let _ = std::fs::remove_file(&path);
microrm::ConnectionPool::open::<S>(path).expect("couldn't connect to database")
}
pub(super) fn test_db_path(identifier: &'static str) -> std::path::PathBuf {
let path = format!(
"{tmpdir}/{identifier}.db",
tmpdir = std::env!("CARGO_TARGET_TMPDIR"),
);
path.replace("::", "_");
path.into()
}
mod macros {
macro_rules! open_test_db {
() => {{
use stdext::function_name;
$crate::common::open_test_helper(function_name!())
}};
}
pub(crate) use open_test_db;
}
pub(crate) use macros::open_test_db;