let version = Camlet_domain.Version.current let test_human_output () = Alcotest.(check string) "human output" "camlet 0.1.0-dev" (Camlet_presentation.Version_output.human version) let test_json_output () = let actual = Camlet_presentation.Version_output.json version |> Yojson.Safe.from_string in let expected = `Assoc [ ("schema", `String "org.camlet.version.v1") ; ( "result" , `Assoc [ ("name", `String "camlet"); ("version", `String "0.1.0-dev") ] ) ] in Alcotest.(check bool) "JSON output" true (Yojson.Safe.equal expected actual) let timestamp value = match Camlet_domain.Timestamp.of_string value with | Ok timestamp -> timestamp | Error message -> Alcotest.fail message let test_timestamp_output () = List.iter (fun (input, expected) -> Alcotest.(check string) input expected (timestamp input |> Camlet_domain.Timestamp.to_string)) [ ("2026-01-02T03:04:05Z", "2026-01-02T03:04:05Z") ; ("2026-01-02T03:04:05.123000Z", "2026-01-02T03:04:05.123Z") ; ( "2026-01-02T04:04:05.123456789012+01:00" , "2026-01-02T03:04:05.123456789012Z" ) ] let test_float_timestamp_precision () = let timestamp = match Camlet_domain.Timestamp.of_float_s 0.123456789 with | Ok value -> value | Error message -> Alcotest.fail message in Alcotest.(check string) "microsecond precision" "1970-01-01T00:00:00.123456Z" (Camlet_domain.Timestamp.to_string timestamp) let test_error_categories () = let open Camlet_domain in List.iter (fun (category, name, exit) -> let error = App_error.make ~category ~code:"test" ~message:"test" in Alcotest.(check string) name name (App_error.category_name category); Alcotest.(check int) name exit (App_error.exit_code error)) [ (Usage, "usage", 2) ; (Configuration, "configuration", 3) ; (Not_found, "not_found", 4) ; (Authentication, "authentication", 5) ; (Authorization, "authorization", 6) ; (Transport, "transport", 7) ; (Protocol, "protocol", 8) ; (External_tool, "external_tool", 9) ; (Consistency, "consistency", 10) ; (Conflict, "conflict", 11) ; (Internal, "internal", 70) ] let () = Alcotest.run "camlet" [ ( "version" , [ Alcotest.test_case "human output" `Quick test_human_output ; Alcotest.test_case "JSON output" `Quick test_json_output ; Alcotest.test_case "timestamp output" `Quick test_timestamp_output ; Alcotest.test_case "float timestamp precision" `Quick test_float_timestamp_precision ; Alcotest.test_case "error categories" `Quick test_error_categories ] ) ]