feat(config): App can take environ variables
- Change log level of SQLx to TRACE
This commit is contained in:
@@ -3,7 +3,6 @@ use email_newsletter_api::{
|
||||
telemetry::{get_subscriber, init_subscriber},
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use secrecy::ExposeSecret;
|
||||
use sqlx::{Connection, Executor, PgConnection, PgPool};
|
||||
use std::net::TcpListener;
|
||||
use uuid::Uuid;
|
||||
@@ -58,17 +57,16 @@ pub async fn spawn_app() -> TestApp {
|
||||
}
|
||||
|
||||
pub async fn configure_test_database(db_config: &DatabaseSettings) -> PgPool {
|
||||
let mut connection =
|
||||
PgConnection::connect(db_config.connection_string_without_db().expose_secret())
|
||||
.await
|
||||
.expect("Failed to connect to Postgres");
|
||||
let mut connection = PgConnection::connect_with(&db_config.without_db())
|
||||
.await
|
||||
.expect("Failed to connect to Postgres");
|
||||
|
||||
connection
|
||||
.execute(format!(r#"CREATE DATABASE "{}";"#, db_config.database_name).as_str())
|
||||
.await
|
||||
.expect("Failed to create database");
|
||||
|
||||
let conn_pool = PgPool::connect(db_config.connection_string().expose_secret())
|
||||
let conn_pool = PgPool::connect_with(db_config.with_db())
|
||||
.await
|
||||
.expect("Failed to connect to PostgreSQL pool");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user