bazzar/crates/testx/src/lib.rs

35 lines
825 B
Rust
Raw Normal View History

2022-06-05 21:03:22 +02:00
#[macro_export]
macro_rules! db_t_ref {
2022-06-05 21:03:22 +02:00
($t: ident) => {
let config = config::default_load(&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::default_load(&mut NoOpts);
$config
.lock()
.database_mut()
.set_url("postgres://postgres@localhost/bazzar_test");
let $db = Database::build($config.clone()).await;
};
}
2022-06-05 21:03:22 +02:00
#[macro_export]
macro_rules! db_rollback {
($t: expr) => {
$t.rollback().await.unwrap();
};
}