use std::time::Duration;
use super::support::stdio;
use crate::mcp::REMOTE_UNSUPPORTED;
use crate::mcp::spawn::{HANDSHAKE_TIMEOUT, connect};
#[test]
fn handshake_timeout_is_ten_seconds() {
assert_eq!(HANDSHAKE_TIMEOUT, Duration::from_secs(10));
}
#[tokio::test]
async fn a_remote_transport_is_refused_with_a_reason() {
let mut server = stdio("remote", "unused", &[]);
server.transport = trusty_mcp::config::McpTransport::Http {
url: "https://example.invalid/mcp".to_string(),
headers: std::collections::BTreeMap::new(),
};
let reason = connect(&server).await.err().expect("must refuse");
assert_eq!(reason, REMOTE_UNSUPPORTED);
}
#[tokio::test]
async fn a_missing_binary_is_refused_with_a_reason() {
let server = stdio("ghost", "/nonexistent/mcp/binary/xyzzy-5428", &[]);
let reason = connect(&server).await.err().expect("must refuse");
assert!(
reason.contains("xyzzy-5428"),
"the reason names the command: {reason}",
);
}
#[tokio::test]
#[cfg(unix)]
async fn a_server_that_speaks_no_mcp_is_refused_with_a_reason() {
let server = stdio("parrot", "/bin/cat", &[]);
let reason = connect(&server).await.err().expect("must refuse");
assert!(
reason.contains("handshake"),
"the reason says what stage failed: {reason}",
);
}