feat: harden community production foundation through story 1.5
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crank_community_mcp::session::{PostgresTransportSessionStore, TransportSessionStore};
|
||||
use crank_registry::PostgresPoolConfig;
|
||||
use crank_registry::{MigrationAuthority, PostgresPoolConfig};
|
||||
use sqlx::postgres::{PgConnectOptions, PgPoolOptions};
|
||||
use time::{OffsetDateTime, format_description::well_known::Rfc3339};
|
||||
|
||||
@@ -13,9 +13,15 @@ fn truncate_to_micros(value: OffsetDateTime) -> OffsetDateTime {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
async fn migrate(database_url: &str) {
|
||||
let pool = sqlx::PgPool::connect(database_url).await.unwrap();
|
||||
MigrationAuthority::apply(&pool).await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn postgres_transport_sessions_survive_store_reconnect() {
|
||||
let database_url = crank_test_support::postgres_schema_url("test_mcp_transport").await;
|
||||
migrate(&database_url).await;
|
||||
let connect_options = database_url.parse::<PgConnectOptions>().unwrap();
|
||||
let pool_config = PostgresPoolConfig::default();
|
||||
let store_a = PostgresTransportSessionStore::connect_with_options_and_pool_config(
|
||||
@@ -61,6 +67,7 @@ async fn postgres_transport_sessions_survive_store_reconnect() {
|
||||
#[tokio::test]
|
||||
async fn postgres_transport_sessions_evict_expired_rows_on_read() {
|
||||
let database_url = crank_test_support::postgres_schema_url("test_mcp_transport").await;
|
||||
migrate(&database_url).await;
|
||||
let connect_options = database_url.parse::<PgConnectOptions>().unwrap();
|
||||
let store = PostgresTransportSessionStore::connect_with_options_and_pool_config(
|
||||
connect_options.clone(),
|
||||
@@ -101,6 +108,7 @@ async fn postgres_transport_sessions_evict_expired_rows_on_read() {
|
||||
#[tokio::test]
|
||||
async fn postgres_transport_session_cleanup_removes_abandoned_expired_rows() {
|
||||
let database_url = crank_test_support::postgres_schema_url("test_mcp_cleanup").await;
|
||||
migrate(&database_url).await;
|
||||
let store = PostgresTransportSessionStore::connect_with_options_and_pool_config(
|
||||
database_url.parse::<PgConnectOptions>().unwrap(),
|
||||
PostgresPoolConfig::default(),
|
||||
|
||||
Reference in New Issue
Block a user