@@ -44,7 +44,7 @@ impl<'a> From<(&'a str, u16, bool)> for EndpointRef<'a> {
44
44
45
45
impl Display for EndpointRef < ' _ > {
46
46
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" } ;
48
48
write ! ( f, "{}://{}:{}" , proto, self . host, self . port)
49
49
}
50
50
}
@@ -287,4 +287,17 @@ mod tests {
287
287
assert_eq ! ( endpoints. next( ) , Some ( EndpointRef :: new( "host3" , 2182 , true ) ) ) ;
288
288
assert_eq ! ( endpoints. next( ) , Some ( EndpointRef :: new( "host1" , 2181 , true ) ) ) ;
289
289
}
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
+ }
290
303
}
0 commit comments