feat: add drop_database for tests

This commit is contained in:
Paul Makles
2023-04-22 16:00:57 +01:00
parent 69ab7e031b
commit b8cda2ec74
3 changed files with 14 additions and 0 deletions

View File

@@ -3,6 +3,10 @@ mod reference;
#[async_trait]
pub trait AbstractMigrations: Sync + Send {
#[cfg(test)]
/// Drop the database
async fn drop_database(&self);
/// Migrate the database
async fn migrate_database(&self) -> Result<(), ()>;
}

View File

@@ -7,6 +7,12 @@ mod scripts;
#[async_trait]
impl AbstractMigrations for MongoDb {
#[cfg(test)]
/// Drop the database
async fn drop_database(&self) {
self.db().drop(None).await.ok();
}
/// Migrate the database
async fn migrate_database(&self) -> Result<(), ()> {
info!("Migrating the database.");

View File

@@ -4,6 +4,10 @@ use super::AbstractMigrations;
#[async_trait]
impl AbstractMigrations for ReferenceDb {
#[cfg(test)]
/// Drop the database
async fn drop_database(&self) {}
/// Migrate the database
async fn migrate_database(&self) -> Result<(), ()> {
// Here you would do your typical migrations if this was a real database.