Added config file for db #9

Merged
phoenix merged 32 commits from db into devel 2025-04-03 13:59:56 +00:00
Showing only changes of commit 55378156ae - Show all commits

View File

@@ -22,6 +22,28 @@ use axum::{
use tower::util::ServiceExt;
// use testcontainers_modules::testcontainers::core::client::
const TEST_DATABASE_URL_ENV: &str = "TEST_DATABASE_URL";
const DEFAULT_TEST_DATABASE_URL: &str =
"postgres://icarus_op_test:password@localhost:5432/icarus_auth_test";
static SETUP: std::sync::Once = std::sync::Once::new();
async fn setup_database() -> sqlx::PgPool {
let database_url = std::env::var(TEST_DATABASE_URL_ENV)
.unwrap_or_else(|_| DEFAULT_TEST_DATABASE_URL.to_string());
let pool = sqlx::PgPool::connect(&database_url)
.await
.expect("Failed to connect to test database");
let migrator = sqlx::migrate::Migrator::new(std::path::Path::new("./migrations"))
.await
.expect("Failed to create migrator");
migrator.run(&pool).await.expect("Failed to run migrations");
// Seed here if needed
pool
}
/*
async fn setup_test(pool: sqlx::PgPool) -> Router {
Router::new()