diff options
author | Clombrong <cromblong@egregore.fun> | 2025-06-26 15:39:10 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-06-26 21:40:53 +0200 |
commit | 763187955aed2c6ff07eee5f31d413bef81075df (patch) | |
tree | 787af060ba43655c301d87132133af16eefc114d /test/native/native_hello.ml | |
parent | 37d47541083c3eaf3ea9f6c3445e8ba926ee609c (diff) |
feat(tests): move test program to common code
Diffstat (limited to 'test/native/native_hello.ml')
-rw-r--r-- | test/native/native_hello.ml | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/test/native/native_hello.ml b/test/native/native_hello.ml index a5f9323..955642c 100644 --- a/test/native/native_hello.ml +++ b/test/native/native_hello.ml @@ -1,33 +1,2 @@ -open! Lwt.Syntax -open! Lwt.Infix -open! Flesh - -let main (stream, push) config = - let+ _auth = Sasl.authenticate (stream, push) config - in match _auth with - | Error (NotAuthorized, Some (_, text)) -> print_endline ("Not authorized: " ^ text) - | Error (MalformedRequest, Some (_, text)) -> print_endline ("Malformed request: " ^ text) - | Error _ -> print_endline "Error!" - | Ok _ -> print_endline "Success!" - - let () = - Lwt_main.run @@ - let config : Sasl.auth_config = { - jid = (Sys.getenv "FLESH_JID"); - password = (Sys.getenv "FLESH_PASSWORD"); - preferred_mechanisms = [Stream.PLAIN] - } - in let domain = (List.nth (String.split_on_char '@' config.jid) 1) in - let* stream, push = Stream.start domain in - Lwt.catch - (fun () -> main (stream, push) config >|= (fun () -> push None)) - (fun exn -> - push None; - (* I suspect JavaScript's [wrap_callback] swallows the Exceptions thrown by - OCaml, so... The next best thing is probably printing something. *) - print_endline - (match exn with - | Stream.InvalidStanza stanza -> "Invalid stanza: " ^ stanza - | _ -> "... and so I stumble back to bed."); - Lwt.fail exn) + Lwt_main.run @@ Hello.main |