Added helper functions
Some checks failed
Rust Build / Check (pull_request) Successful in 49s
Rust Build / Test Suite (pull_request) Failing after 1m1s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 47s
Rust Build / build (pull_request) Successful in 1m11s
Some checks failed
Rust Build / Check (pull_request) Successful in 49s
Rust Build / Test Suite (pull_request) Failing after 1m1s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 47s
Rust Build / build (pull_request) Successful in 1m11s
This commit is contained in:
@@ -22,6 +22,28 @@ use axum::{
|
|||||||
use tower::util::ServiceExt;
|
use tower::util::ServiceExt;
|
||||||
// use testcontainers_modules::testcontainers::core::client::
|
// 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 {
|
async fn setup_test(pool: sqlx::PgPool) -> Router {
|
||||||
Router::new()
|
Router::new()
|
||||||
|
Reference in New Issue
Block a user