Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor lwt client test #26

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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