forked from jmug/stoatchat
feat: add drop_database for tests
This commit is contained in:
@@ -3,6 +3,10 @@ mod reference;
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait AbstractMigrations: Sync + Send {
|
pub trait AbstractMigrations: Sync + Send {
|
||||||
|
#[cfg(test)]
|
||||||
|
/// Drop the database
|
||||||
|
async fn drop_database(&self);
|
||||||
|
|
||||||
/// Migrate the database
|
/// Migrate the database
|
||||||
async fn migrate_database(&self) -> Result<(), ()>;
|
async fn migrate_database(&self) -> Result<(), ()>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ mod scripts;
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl AbstractMigrations for MongoDb {
|
impl AbstractMigrations for MongoDb {
|
||||||
|
#[cfg(test)]
|
||||||
|
/// Drop the database
|
||||||
|
async fn drop_database(&self) {
|
||||||
|
self.db().drop(None).await.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/// Migrate the database
|
/// Migrate the database
|
||||||
async fn migrate_database(&self) -> Result<(), ()> {
|
async fn migrate_database(&self) -> Result<(), ()> {
|
||||||
info!("Migrating the database.");
|
info!("Migrating the database.");
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ use super::AbstractMigrations;
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl AbstractMigrations for ReferenceDb {
|
impl AbstractMigrations for ReferenceDb {
|
||||||
|
#[cfg(test)]
|
||||||
|
/// Drop the database
|
||||||
|
async fn drop_database(&self) {}
|
||||||
|
|
||||||
/// Migrate the database
|
/// Migrate the database
|
||||||
async fn migrate_database(&self) -> Result<(), ()> {
|
async fn migrate_database(&self) -> Result<(), ()> {
|
||||||
// Here you would do your typical migrations if this was a real database.
|
// Here you would do your typical migrations if this was a real database.
|
||||||
|
|||||||
Reference in New Issue
Block a user