Skip to content

Commit

Permalink
test(server): fix streaming_body incorrect test
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Mar 1, 2018
1 parent 4351ed1 commit 9990e27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ fn streaming_body() {
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap(), &core.handle()).unwrap();
let addr = listener.local_addr().unwrap();

let (tx, rx) = oneshot::channel();
thread::spawn(move || {
let mut tcp = connect(&addr);
tcp.write_all(b"GET / HTTP/1.1\r\n\r\n").unwrap();
Expand All @@ -1045,9 +1046,12 @@ fn streaming_body() {
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()
.into_future()
.map_err(|_| unreachable!())
Expand All @@ -1064,7 +1068,7 @@ fn streaming_body() {
.map(|_| ())
});

core.run(fut).unwrap();
core.run(fut.join(rx)).unwrap();
}

#[test]
Expand Down

0 comments on commit 9990e27

Please sign in to comment.