Skip to content

Commit

Permalink
Refactor lwt client test (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
dx3mod authored Sep 8, 2024
1 parent 71d93b1 commit cd63149
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions tests/lwt/test_lwt_client.ml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit cd63149

Please sign in to comment.