test(server): fix streaming_body incorrect test

This commit is contained in:
Sean McArthur
2018-03-01 14:13:02 -08:00
parent 4351ed1d13
commit 9990e273f6

View File

@@ -1029,6 +1029,7 @@ fn streaming_body() {
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap(), &core.handle()).unwrap(); let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap(), &core.handle()).unwrap();
let addr = listener.local_addr().unwrap(); let addr = listener.local_addr().unwrap();
let (tx, rx) = oneshot::channel();
thread::spawn(move || { thread::spawn(move || {
let mut tcp = connect(&addr); let mut tcp = connect(&addr);
tcp.write_all(b"GET / HTTP/1.1\r\n\r\n").unwrap(); tcp.write_all(b"GET / HTTP/1.1\r\n\r\n").unwrap();
@@ -1045,9 +1046,12 @@ fn streaming_body() {
break; break;
} }
} }
assert_eq!(sum, 1_007_089); assert_eq!(sum, 100_789);
let _ = tx.send(());
}); });
let rx = rx.map_err(|_| panic!("thread panicked"));
let fut = listener.incoming() let fut = listener.incoming()
.into_future() .into_future()
.map_err(|_| unreachable!()) .map_err(|_| unreachable!())
@@ -1064,7 +1068,7 @@ fn streaming_body() {
.map(|_| ()) .map(|_| ())
}); });
core.run(fut).unwrap(); core.run(fut.join(rx)).unwrap();
} }
#[test] #[test]