Skip to content

Commit 376b21d

Browse files
committed
fix: wrong proto in Endpoint format
1 parent 45dec8d commit 376b21d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/endpoint.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'a> From<(&'a str, u16, bool)> for EndpointRef<'a> {
4444

4545
impl Display for EndpointRef<'_> {
4646
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
47-
let proto = if self.tls { "tcp" } else { "tcp+tls" };
47+
let proto = if self.tls { "tcp+tls" } else { "tcp" };
4848
write!(f, "{}://{}:{}", proto, self.host, self.port)
4949
}
5050
}
@@ -287,4 +287,17 @@ mod tests {
287287
assert_eq!(endpoints.next(), Some(EndpointRef::new("host3", 2182, true)));
288288
assert_eq!(endpoints.next(), Some(EndpointRef::new("host1", 2181, true)));
289289
}
290+
291+
#[test]
292+
fn test_endpoint_display() {
293+
use super::{EndpointRef, Ref};
294+
295+
let endpoint = EndpointRef::new("host", 2181, false);
296+
assert_eq!(endpoint.to_string(), "tcp://host:2181");
297+
assert_eq!(endpoint.to_value().to_string(), "tcp://host:2181");
298+
299+
let endpoint = EndpointRef::new("host", 2182, true);
300+
assert_eq!(endpoint.to_string(), "tcp+tls://host:2182");
301+
assert_eq!(endpoint.to_value().to_string(), "tcp+tls://host:2182");
302+
}
290303
}

0 commit comments

Comments
 (0)