mod common_traits;
pub use common_traits::*;
#[cfg(feature = "with-tokio-postgres")]
pub mod tokio_postgres;
#[cfg(feature = "with-sqlx")]
pub mod sqlx_postgres;
mod error;
pub use error::*;
pub use testkit_core::{
DatabaseBackend, DatabaseConfig, DatabaseName, DatabasePool, TestContext,
TestDatabaseConnection, TestDatabaseInstance,
};
#[cfg(feature = "with-tokio-postgres")]
pub use tokio_postgres::*;
#[cfg(feature = "with-sqlx")]
pub use sqlx_postgres::*;
pub use testkit_core::with_connection;
pub use testkit_core::with_connection_string;
pub use testkit_core::with_database;
#[cfg(feature = "with-tokio-postgres")]
pub use testkit_core::{with_boxed_database, with_boxed_database_config};
pub use testkit_core::boxed_async;
#[cfg(feature = "with-sqlx")]
pub async fn with_sqlx_connection<F, R, E>(
connection_string: impl Into<String>,
operation: F,
) -> Result<R, PostgresError>
where
F: FnOnce(&mut sqlx_postgres::SqlxConnection) -> futures::future::BoxFuture<'_, Result<R, E>>,
E: std::error::Error + Send + Sync + 'static,
{
sqlx_postgres::SqlxConnection::with_connection(connection_string, operation).await
}
#[cfg(feature = "with-tokio-postgres")]
pub async fn with_postgres_connection<F, R, E>(
connection_string: impl Into<String>,
operation: F,
) -> Result<R, PostgresError>
where
F: FnOnce(&tokio_postgres::PostgresConnection) -> futures::future::BoxFuture<'_, Result<R, E>>,
E: std::error::Error + Send + Sync + 'static,
{
tokio_postgres::PostgresConnection::with_connection(connection_string, operation).await
}
#[allow(dead_code)]
async fn boxed_example() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}