From 22bd71354eafd9e7ef4d4579f9bf5e6181d44604 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 27 Jun 2025 14:58:14 -0600 Subject: test: convert build_client to a generic function --- tests/authorization/server_test.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/authorization/server_test.rs b/tests/authorization/server_test.rs index 5e99fdac..40cc270f 100644 --- a/tests/authorization/server_test.rs +++ b/tests/authorization/server_test.rs @@ -34,21 +34,23 @@ mod tests { .expect("Failed to connect to server") } - async fn build_client( - addr: SocketAddr, - ) -> tonic_health::pb::health_client::HealthClient { - tonic_health::pb::health_client::HealthClient::new(build_channel(addr).await) + async fn build_client(addr: SocketAddr, f: F) -> T + where + F: FnOnce(Channel) -> T, + { + f(build_channel(addr).await) } #[tokio::test] async fn test_health_check_service() { let (addr, server) = start_server().await; - let mut client = build_client(addr).await; + let mut client = build_client(addr, tonic_health::pb::health_client::HealthClient::new).await; + let request = tonic::Request::new(tonic_health::pb::HealthCheckRequest { service: String::new(), }); - let response = client.check(request).await; + assert!(response.is_ok()); assert_eq!( response.unwrap().into_inner().status(), -- cgit v1.2.3