diff options
| author | mo khan <mo@mokhan.ca> | 2025-06-27 14:58:14 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-06-27 14:58:14 -0600 |
| commit | 22bd71354eafd9e7ef4d4579f9bf5e6181d44604 (patch) | |
| tree | 805343768287f9ade4da5152600acc862fde703a /tests/authorization/server_test.rs | |
| parent | 2309a49fddd189e5dc9da1e7bf979864f02701e0 (diff) | |
test: convert build_client to a generic function
Diffstat (limited to 'tests/authorization/server_test.rs')
| -rw-r--r-- | tests/authorization/server_test.rs | 14 |
1 files 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<Channel> { - tonic_health::pb::health_client::HealthClient::new(build_channel(addr).await) + async fn build_client<T, F>(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(), |
