24 lines
839 B
Rust
24 lines
839 B
Rust
use std::time::Duration;
|
|
|
|
#[tokio::test]
|
|
#[ignore]
|
|
async fn nats_integration_tests_are_gated_and_fast_fail() {
|
|
let url = std::env::var("CONTROL_TEST_NATS_URL").expect("CONTROL_TEST_NATS_URL is required");
|
|
|
|
let without_scheme = url.strip_prefix("nats://").unwrap_or(url.as_str());
|
|
let hostport = without_scheme.split('/').next().unwrap_or(without_scheme);
|
|
let mut parts = hostport.split(':');
|
|
let host = parts.next().unwrap_or("127.0.0.1");
|
|
let port: u16 = parts
|
|
.next()
|
|
.unwrap_or("4222")
|
|
.parse()
|
|
.expect("invalid port in CONTROL_TEST_NATS_URL");
|
|
|
|
let connect = tokio::net::TcpStream::connect((host, port));
|
|
tokio::time::timeout(Duration::from_secs(2), connect)
|
|
.await
|
|
.expect("tcp connect to NATS timed out")
|
|
.expect("failed to connect to NATS");
|
|
}
|