Testability ddd repository (#55)

This commit is contained in:
kos-for-juspay
2022-12-03 07:18:51 +02:00
committed by GitHub
parent 35289df715
commit 200a085fd0
116 changed files with 3551 additions and 1653 deletions

View File

@ -2,9 +2,10 @@ use async_bb8_diesel::{AsyncConnection, ConnectionError, ConnectionManager};
use bb8::{CustomizeConnection, PooledConnection};
use diesel::PgConnection;
use crate::configs::settings::{Database, Settings};
use crate::configs::settings::Database;
pub type PgPool = bb8::Pool<async_bb8_diesel::ConnectionManager<PgConnection>>;
pub type PgPooledConn = async_bb8_diesel::Connection<PgConnection>;
pub type RedisPool = std::sync::Arc<redis_interface::RedisConnectionPool>;
@ -25,12 +26,14 @@ impl CustomizeConnection<PgPooledConn, ConnectionError> for TestTransaction {
}
}
pub async fn redis_connection(conf: &Settings) -> redis_interface::RedisConnectionPool {
pub async fn redis_connection(
conf: &crate::configs::settings::Settings,
) -> redis_interface::RedisConnectionPool {
redis_interface::RedisConnectionPool::new(&conf.redis).await
}
#[allow(clippy::expect_used)]
pub async fn make_pg_pool(database: &Database, test_transaction: bool) -> PgPool {
pub async fn diesel_make_pg_pool(database: &Database, test_transaction: bool) -> PgPool {
let database_url = format!(
"postgres://{}:{}@{}:{}/{}",
database.username, database.password, database.host, database.port, database.dbname