use crate::brain::agent::service::helpers::handshake_timeout_for;
use std::time::Duration;
#[test]
fn cli_providers_get_ten_minutes() {
assert_eq!(handshake_timeout_for(true, None), Duration::from_secs(600));
assert_eq!(
handshake_timeout_for(true, Some("http://localhost:1234/v1/chat/completions")),
Duration::from_secs(600),
);
assert_eq!(
handshake_timeout_for(true, Some("https://api.openai.com/v1/chat/completions")),
Duration::from_secs(600),
);
}
#[test]
fn local_http_gets_ninety_seconds() {
for url in [
"http://localhost:1234/v1/chat/completions",
"http://127.0.0.1:8080/v1/chat/completions",
"http://[::1]:11434/api/chat",
"http://0.0.0.0:8000/v1/chat/completions",
"http://192.168.1.42:11434/api/chat",
"http://10.0.0.5:8080/v1",
"http://172.20.0.10:8000/v1",
"http://my-rig.local:1234/v1/chat/completions",
] {
assert_eq!(
handshake_timeout_for(false, Some(url)),
Duration::from_secs(90),
"expected 90s for local URL: {}",
url,
);
}
}
#[test]
fn cloud_http_gets_thirty_seconds() {
for url in [
"https://integrate.api.nvidia.com/v1/chat/completions",
"https://api.openai.com/v1/chat/completions",
"https://api.anthropic.com/v1/messages",
"https://api.z.ai/api/coding/paas/v4/chat/completions",
"https://opencode.ai/zen/go/v1/chat/completions",
"https://openrouter.ai/api/v1/chat/completions",
"https://api.minimax.io/v1/chat/completions",
"https://api.moonshot.ai/v1/chat/completions",
] {
assert_eq!(
handshake_timeout_for(false, Some(url)),
Duration::from_secs(30),
"expected 30s for cloud URL: {}",
url,
);
}
}
#[test]
fn missing_base_url_defaults_to_cloud_timeout() {
assert_eq!(handshake_timeout_for(false, None), Duration::from_secs(30));
}