diff --git a/tests/tests.rs b/tests/tests.rs index 78128d4b..d29f1a9a 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -781,20 +781,11 @@ where async fn test_proxy_with_setting(https: bool, http2: bool, proxy_http2: bool) { dbg!((https, http2, proxy_http2)); - let (tx, rx) = flume::unbounded(); let (proxy_port, proxy_serve) = bind_proxy( - service_fn(move |mut req| { - let tx = tx.clone(); - async move { - req.headers_mut() - .insert("x-oha-test-through-proxy", "true".parse().unwrap()); - - tx.send(req).unwrap(); - - let res = Response::new("Hello World".to_string()); - Ok::<_, Infallible>(res) - } + service_fn(|_req| async { + let res = Response::new("Hello World".to_string()); + Ok::<_, Infallible>(res) }), proxy_http2, ) @@ -818,23 +809,24 @@ async fn test_proxy_with_setting(https: bool, http2: bool, proxy_http2: bool) { } proc.stdin(std::process::Stdio::null()) - .stdout(std::process::Stdio::null()) + .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::null()); - proc.spawn().unwrap().wait().await.unwrap(); - - let req = rx.try_recv().unwrap(); + let stdout = proc + .spawn() + .unwrap() + .wait_with_output() + .await + .unwrap() + .stdout; - assert_eq!( - req.headers().get("x-oha-test-through-proxy").unwrap(), - "true" - ); + assert!(String::from_utf8(stdout).unwrap().contains("Hello World"),); } -#[tokio::test] +#[tokio::test(flavor = "multi_thread", worker_threads = 64)] async fn test_proxy() { for https in [false, true] { for http2 in [false, true] { - for proxy_http2 in [false, true] { + for proxy_http2 in [false] { test_proxy_with_setting(https, http2, proxy_http2).await; } }