From 94431a578b103c1de0334d83e3d4db2f7b2ce019 Mon Sep 17 00:00:00 2001 From: dx3mod Date: Sun, 8 Sep 2024 22:26:27 +0300 Subject: [PATCH] Refactor lwt client test --- tests/lwt/test_lwt_client.ml | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/tests/lwt/test_lwt_client.ml b/tests/lwt/test_lwt_client.ml index 83789f9..de0d28c 100644 --- a/tests/lwt/test_lwt_client.ml +++ b/tests/lwt/test_lwt_client.ml @@ -1,33 +1,14 @@ open Alcotest let init_test_correct_address _ () = - Lwt.catch - (fun () -> - let%lwt _client = - Nats_client_lwt.make { port = 4222; host = "127.0.0.1" } - in - Lwt.return_unit) - (function - | Nats_client_lwt.Connection.Connection_refused -> Lwt.return_unit - | exn -> - Alcotest.fail - (Printf.sprintf "Unexpected exception: %s" (Printexc.to_string exn))) + let%lwt _ = Nats_client_lwt.make { port = 4222; host = "127.0.0.1" } in + Lwt.return_unit let init_test_wrong_address _ () = - Lwt.catch - (fun () -> - let%lwt _client = - Nats_client_lwt.make { port = 42222; host = "127.0.0.1" } - in - let _ = - fail "Expected Connection_refused exception, but none was raised" - in - Lwt.return_unit) - (function - | Nats_client_lwt.Connection.Connection_refused -> Lwt.return_unit - | exn -> - Alcotest.fail - (Printf.sprintf "Unexpected exception: %s" (Printexc.to_string exn))) + try%lwt + let%lwt _ = Nats_client_lwt.make { port = 42222; host = "127.0.0.1" } in + fail "Expected Connection_refused exception, but none was raised" + with Nats_client_lwt.Connection.Connection_refused -> Lwt.return_unit let connect_test _ () = let%lwt client = Nats_client_lwt.make { port = 4222; host = "127.0.0.1" } in