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
@@ -33,4 +33,5 @@ uuid.workspace = true
[dev-dependencies]
crank-mapping = { path = "../../crates/crank-mapping" }
crank-schema = { path = "../../crates/crank-schema" }
crank-test-support = { path = "../../crates/crank-test-support" }
reqwest.workspace = true
+3 -19
View File
@@ -127,7 +127,7 @@ fn mcp_api_rate_limit_config_from_env() -> Result<RequestRateLimitConfig, Box<dy
mod tests {
use std::{
collections::BTreeMap,
env, io,
io,
sync::{Arc, Mutex},
time::Duration,
};
@@ -158,7 +158,6 @@ mod tests {
use futures_util::stream;
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
use sqlx::{Executor, postgres::PgPoolOptions};
use time::{OffsetDateTime, format_description::well_known::Rfc3339};
use tokio::net::TcpListener;
use tokio::time::sleep;
@@ -1792,23 +1791,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 admin_pool = PgPoolOptions::new()
.max_connections(1)
.connect(&database_url)
.await
.unwrap();
let schema = format!("test_mcp_server_{}", uuid::Uuid::now_v7().simple());
admin_pool
.execute(sqlx::query(&format!("create schema {schema}")))
.await
.unwrap();
PostgresRegistry::connect(&format!("{database_url}?options=-csearch_path%3D{schema}"))
.await
.unwrap()
let database_url = crank_test_support::postgres_schema_url("test_mcp_server").await;
PostgresRegistry::connect(&database_url).await.unwrap()
}
fn test_operation(base_url: &str, name: &str) -> Operation<Schema, MappingSet> {