Skip to content

Commit 319b852

Browse files
committed
Fixed a broken test
1 parent 28bceac commit 319b852

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

tests/test_basic.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,23 +573,16 @@ fn test_tuple_decoding_regression() {
573573

574574
#[test]
575575
fn test_invalid_protocol() {
576-
let ctx = TestContext::new();
577-
let (addr, url) = match *ctx.server.get_client_addr() {
578-
redis::ConnectionAddr::Tcp(ref host, port) => {
579-
(format!("{}:{}", host, port),
580-
format!("redis://{}:{}", host, port))
581-
},
582-
_ => { return; }
583-
};
584-
585576
use std::thread;
586577
use std::error::Error;
587578
use std::io::Write;
588579
use std::net::TcpListener;
589580
use redis::{RedisResult, Parser};
590581

582+
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
583+
let port = listener.local_addr().unwrap().port();
584+
591585
let child = thread::spawn(move || -> Result<(), Box<Error + Send + Sync>> {
592-
let listener = try!(TcpListener::bind(&addr[..]));
593586
let mut stream = try!(listener.incoming().next().unwrap());
594587
// read the request and respond with garbage
595588
let _: redis::Value = try!(Parser::new(&mut stream).parse_value());
@@ -600,7 +593,7 @@ fn test_invalid_protocol() {
600593
});
601594
sleep(Duration::from_millis(100));
602595
// some work here
603-
let cli = redis::Client::open(&url[..]).unwrap();
596+
let cli = redis::Client::open(&format!("redis://127.0.0.1:{}", port)[..]).unwrap();
604597
let con = cli.get_connection().unwrap();
605598

606599
let mut result: redis::RedisResult<u8>;

0 commit comments

Comments
 (0)