proxy: fix tcp_with_no_orig_dst test (#229)

Sometimes, the try_read will return a connection error, sometimes it
will just return EOF. Handle both cases.

Closes #226
This commit is contained in:
Sean McArthur 2018-01-29 15:15:06 -08:00 committed by GitHub
parent 4a76c6448b
commit 9720a32de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -227,7 +227,9 @@ fn inbound_tcp() {
fn tcp_with_no_orig_dst() {
let _ = env_logger::init();
let srv = server::tcp().run();
let srv = server::tcp()
.accept(move |_| "don't read me")
.run();
let ctrl = controller::new().run();
let proxy = proxy::new()
.controller(ctrl)
@ -240,7 +242,11 @@ fn tcp_with_no_orig_dst() {
let tcp_client = client.connect();
tcp_client.write("custom tcp hello");
assert!(tcp_client.try_read().is_err());
let read = tcp_client
.try_read()
// This read might be an error, or an empty vec
.unwrap_or_else(|_| Vec::new());
assert_eq!(read, b"");
}
#[test]