2022-06-05 21:03:22 +02:00
|
|
|
#[macro_export]
|
2022-06-09 15:28:15 +02:00
|
|
|
macro_rules! db_t_ref {
|
2022-06-05 21:03:22 +02:00
|
|
|
($t: ident) => {
|
2023-06-20 07:03:15 +02:00
|
|
|
let config = config::load("../../tests/myco.toml", &mut NoOpts);
|
2022-06-05 21:03:22 +02:00
|
|
|
config
|
|
|
|
.lock()
|
|
|
|
.database_mut()
|
2023-06-20 07:03:15 +02:00
|
|
|
.set_url("postgres://postgres@localhost/myco_test");
|
2022-06-05 21:03:22 +02:00
|
|
|
|
|
|
|
let db = Database::build(config).await;
|
|
|
|
let pool = db.pool();
|
|
|
|
let mut $t = pool.begin().await.unwrap();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-06-09 15:28:15 +02:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! db {
|
|
|
|
($config: ident, $db: ident) => {
|
2023-06-20 07:03:15 +02:00
|
|
|
let $config = config::load("../../tests/myco.toml", &mut NoOpts);
|
2022-06-09 15:28:15 +02:00
|
|
|
$config
|
|
|
|
.lock()
|
|
|
|
.database_mut()
|
2023-06-20 07:03:15 +02:00
|
|
|
.set_url("postgres://postgres@localhost/myco_test");
|
2022-06-09 15:28:15 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
};
|
|
|
|
}
|