Fail if PoolKey::new() cant find port

This commit is contained in:
Martin Algesten
2019-10-20 11:45:37 +02:00
parent f58ecac620
commit acb40cc1a3

View File

@@ -52,9 +52,20 @@ struct PoolKey {
impl PoolKey { impl PoolKey {
fn new(url: &Url) -> Self { fn new(url: &Url) -> Self {
let port = if cfg!(test) {
if let Some(p) = url.port_or_known_default() {
Some(p)
} else if url.scheme() == "test" {
Some(42)
} else {
None
}
} else {
url.port_or_known_default()
};
PoolKey { PoolKey {
hostname: url.host_str().unwrap_or(DEFAULT_HOST).into(), hostname: url.host_str().unwrap_or(DEFAULT_HOST).into(),
port: url.port_or_known_default().unwrap_or(0), port: port.expect("Failed to get port for pool key"),
} }
} }
} }