My agentic slop goes here. Not intended for anyone else!
at jsont 2.2 kB view raw
1open Printf 2open Jmap 3 4let test_session_wire_type () = 5 printf "Testing Session WIRE_TYPE implementation...\n"; 6 7 (* Use the Session module *) 8 let open Session in 9 10 (* Create a basic session *) 11 let capabilities = Hashtbl.create 1 in 12 Hashtbl.add capabilities "urn:ietf:params:jmap:core" 13 (`Assoc [ 14 ("maxSizeUpload", `Int 50_000_000); 15 ("maxConcurrentUpload", `Int 4); 16 ("maxSizeRequest", `Int 10_000_000); 17 ("maxConcurrentRequests", `Int 4); 18 ("maxCallsInRequest", `Int 16); 19 ("maxObjectsInGet", `Int 500); 20 ("maxObjectsInSet", `Int 500); 21 ("collationAlgorithms", `List [`String "i;unicode-casemap"]) 22 ]); 23 24 let accounts = Hashtbl.create 0 in 25 let primary_accounts = Hashtbl.create 0 in 26 27 let session = Session.v 28 ~capabilities 29 ~accounts 30 ~primary_accounts 31 ~username:"test@example.com" 32 ~api_url:(Uri.of_string "https://example.com/jmap/") 33 ~download_url:(Uri.of_string "https://example.com/download/{accountId}/{blobId}/{name}") 34 ~upload_url:(Uri.of_string "https://example.com/upload/{accountId}/") 35 ~event_source_url:(Uri.of_string "https://example.com/events/") 36 ~state:"test-state" 37 () in 38 39 (* Test validation *) 40 printf "Testing validation...\n"; 41 (match Session.validate session with 42 | Ok () -> printf "✓ Session validation passed\n" 43 | Error msg -> printf "✗ Session validation failed: %s\n" msg); 44 45 (* Test pretty printing *) 46 printf "Testing pretty printing...\n"; 47 Format.printf "Session (pp): %a\n" Session.pp session; 48 Format.printf "Session (pp_hum):\n%a\n" Session.pp_hum session; 49 50 (* Test JSON roundtrip *) 51 printf "Testing JSON serialization...\n"; 52 let json = Session.to_json session in 53 (match Session.of_json json with 54 | Ok session2 -> 55 printf "✓ JSON roundtrip successful\n"; 56 (match Session.validate session2 with 57 | Ok () -> printf "✓ Deserialized session is valid\n" 58 | Error msg -> printf "✗ Deserialized session validation failed: %s\n" msg) 59 | Error msg -> printf "✗ JSON roundtrip failed: %s\n" msg); 60 61 printf "Session WIRE_TYPE implementation test completed.\n" 62 63let () = test_session_wire_type ()