Skip to content

Commit

Permalink
feat(rust): start a new sql file for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Jan 10, 2025
1 parent bbcd779 commit ad01b0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,27 @@ where
let db = SqlxDatabase::create_sqlite(db_file.path()).await?;
rethrow("SQLite on disk", f(db)).await?;

// only run the postgres tests if the OCKAM_POSTGRES_* environment variables are set
// only run the postgres tests if the OCKAM_DATABASE_CONNECTION_URL environment variables is set
if let Ok(db) = SqlxDatabase::create_new_postgres().await {
rethrow("Postgres local", f(db.clone())).await?;
db.drop_all_postgres_tables().await?;
};
Ok(())
}

/// This function can be used to avoid running a test if the postgres database is used.
pub async fn without_postgres<F, Fut, R>(f: F) -> std::result::Result<(), R>
where
F: Fn() -> Fut + Send + Sync + 'static,
Fut: Future<Output = std::result::Result<(), R>> + Send + 'static,
{
// only run the postgres tests if the OCKAM_DATABASE_CONNECTION_URL environment variables is not set
if let Err(_) = SqlxDatabase::create_new_postgres().await {
f().await?
};
Ok(())
}

/// This function can be used to run some test code with the 3 different databases implementations
/// of the application database
pub async fn with_application_dbs<F, Fut>(f: F) -> Result<()>
Expand Down

0 comments on commit ad01b0d

Please sign in to comment.