use turbomcp_proxy::runtime::RuntimeProxyBuilder;
#[tokio::test]
async fn test_stdio_to_stdio_proxy_builds() {
use tokio::time::{Duration, timeout};
let result = timeout(
Duration::from_secs(5),
RuntimeProxyBuilder::new()
.with_stdio_backend("python", vec!["server.py".to_string()])
.with_stdio_frontend()
.build(),
)
.await;
match result {
Ok(Err(_)) => {} Ok(Ok(_)) => {} Err(_) => {} }
}
#[tokio::test]
async fn test_stdio_to_http_proxy_builds() {
use tokio::time::{Duration, timeout};
let result = timeout(
Duration::from_secs(5),
RuntimeProxyBuilder::new()
.with_stdio_backend("python", vec!["server.py".to_string()])
.with_http_frontend("127.0.0.1:0")
.build(),
)
.await;
match result {
Ok(Err(_)) => {} Ok(Ok(_)) => {} Err(_) => {} }
}
#[tokio::test]
async fn test_builder_validation() {
use tokio::time::{Duration, timeout};
let result = timeout(
Duration::from_secs(5),
RuntimeProxyBuilder::new()
.with_http_frontend("127.0.0.1:3000")
.build(),
)
.await;
match result {
Ok(Err(_)) => {} _ => panic!("Should fail validation for missing backend"),
}
let result = timeout(
Duration::from_secs(5),
RuntimeProxyBuilder::new()
.with_stdio_backend("python", vec!["server.py".to_string()])
.build(),
)
.await;
match result {
Ok(Err(_)) => {} _ => panic!("Should fail validation for missing frontend"),
}
}
#[test]
fn test_timeout_validation() {
use turbomcp_proxy::runtime::MAX_TIMEOUT_MS;
let result = RuntimeProxyBuilder::new().with_timeout(MAX_TIMEOUT_MS + 1);
assert!(result.is_err());
}
#[tokio::test]
async fn test_builder_with_valid_config() {
use tokio::time::{Duration, timeout};
let result = timeout(
Duration::from_secs(5),
RuntimeProxyBuilder::new()
.with_stdio_backend("python", vec!["server.py".to_string()])
.with_http_frontend("127.0.0.1:3000")
.with_request_size_limit(1024 * 1024)
.with_timeout(10_000)
.expect("Valid timeout should succeed")
.with_metrics(true)
.build(),
)
.await;
match result {
Ok(Err(_)) => {} Ok(Ok(_)) => {} Err(_) => {} }
}