Use testcontainers for Rust PostgreSQL tests
Deploy / deploy (push) Successful in 1m45s
CI / Rust Checks (push) Failing after 5m38s
CI / UI Checks (push) Has been skipped
CI / Frontend E2E (push) Has been skipped
CI / Deployment Manifests (push) Has been skipped

This commit is contained in:
github-ops
2026-06-21 03:17:06 +00:00
parent ac45d5dc2d
commit d01c8e1f1a
15 changed files with 1069 additions and 129 deletions
+1
View File
@@ -35,5 +35,6 @@ uuid.workspace = true
[dev-dependencies]
async-trait = "0.1"
crank-test-support = { path = "../../crates/crank-test-support" }
reqwest.workspace = true
serial_test = "3"
+2 -21
View File
@@ -193,7 +193,6 @@ mod tests {
use crank_schema::{Schema, SchemaKind};
use serde_json::{Value, json};
use serial_test::serial;
use sqlx::{Connection, Executor, PgConnection};
use tokio::net::TcpListener;
use crate::{
@@ -2229,26 +2228,8 @@ mod tests {
}
async fn test_registry() -> PostgresRegistry {
let database_url = env::var("TEST_DATABASE_URL")
.unwrap_or_else(|_| "postgres://crank:crank@127.0.0.1:15432/crank".to_owned());
let mut admin_connection = PgConnection::connect(&database_url).await.unwrap();
let schema = format!(
"test_admin_api_{}_{}",
std::process::id(),
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_nanos()
);
admin_connection
.execute(sqlx::query(&format!("create schema {schema}")))
.await
.unwrap();
let registry =
PostgresRegistry::connect(&format!("{database_url}?options=-csearch_path%3D{schema}"))
.await
.unwrap();
let database_url = crank_test_support::postgres_schema_url("test_admin_api").await;
let registry = PostgresRegistry::connect(&database_url).await.unwrap();
let password_hash = hash_password(TEST_AUTH_PASSWORD, TEST_PASSWORD_PEPPER).unwrap();
let user_id = registry
.upsert_bootstrap_user(TEST_AUTH_EMAIL, "Test Owner", &password_hash)