bazzar/crates/testx/src/lib.rs
2022-11-14 20:32:28 +01:00

35 lines
863 B
Rust

#[macro_export]
macro_rules! db_t_ref {
($t: ident) => {
let config = config::load("../../tests/bazzar.toml", &mut NoOpts);
config
.lock()
.database_mut()
.set_url("postgres://postgres@localhost/bazzar_test");
let db = Database::build(config).await;
let pool = db.pool();
let mut $t = pool.begin().await.unwrap();
};
}
#[macro_export]
macro_rules! db {
($config: ident, $db: ident) => {
let $config = config::load("../../tests/bazzar.toml", &mut NoOpts);
$config
.lock()
.database_mut()
.set_url("postgres://postgres@localhost/bazzar_test");
let $db = Database::build($config.clone()).await;
};
}
#[macro_export]
macro_rules! db_rollback {
($t: expr) => {
$t.rollback().await.unwrap();
};
}