Server-Sent Events (SSE) parser and serializer
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

sse: shorten test names (merlint E335)

+12 -12
+12 -12
test/test_sse.ml
··· 47 47 48 48 (* Source: WHATWG §9.2.6, Example 4. 49 49 "data:test" followed by EOF (no trailing blank line) → no event dispatched. *) 50 - let test_spec_example_no_trailing_newline () = 50 + let test_spec_no_trailing_nl () = 51 51 let r = parse "data:test\n" in 52 52 Alcotest.(check events) "no dispatch without blank line" [] r 53 53 54 54 (* Source: WHATWG §9.2.6, Example 4 continued. 55 55 "data:test" with trailing blank line → one event. *) 56 - let test_spec_example_with_trailing_newline () = 56 + let test_spec_with_trailing_nl () = 57 57 let r = parse "data:test\n\n" in 58 58 Alcotest.(check events) "dispatch with blank line" [ ev "test" ] r 59 59 ··· 65 65 let r = parse "event:add\ndata:73857293\n\n" in 66 66 Alcotest.(check events) "named event" [ ev ~event:"add" "73857293" ] r 67 67 68 - let test_event_type_resets_after_dispatch () = 68 + let test_event_type_resets () = 69 69 let r = parse "event:custom\ndata:first\n\ndata:second\n\n" in 70 70 Alcotest.(check events) 71 71 "event type resets" ··· 180 180 let r = parse "data: hello\n\n" in 181 181 Alcotest.(check events) "one leading space stripped" [ ev "hello" ] r 182 182 183 - let test_double_space_only_one_stripped () = 183 + let test_double_space_strip () = 184 184 let r = parse "data: hello\n\n" in 185 185 Alcotest.(check events) "only one space stripped" [ ev " hello" ] r 186 186 ··· 196 196 let r = parse "data\n\n" in 197 197 Alcotest.(check events) "field with no colon: empty value" [ ev "" ] r 198 198 199 - let test_data_with_colon_in_value () = 199 + let test_data_colon_value () = 200 200 let r = parse "data:foo:bar:baz\n\n" in 201 201 Alcotest.(check events) "colons in value preserved" [ ev "foo:bar:baz" ] r 202 202 ··· 243 243 let r = parse_chunks [ "da"; "ta:hel"; "lo\n\n" ] in 244 244 Alcotest.(check events) "data split across chunks" [ ev "hello" ] r 245 245 246 - let test_event_split_at_blank_line () = 246 + let test_event_split_blank () = 247 247 let r = parse_chunks [ "data:hello\n"; "\ndata:world\n\n" ] in 248 248 Alcotest.(check events) "split at blank line" [ ev "hello"; ev "world" ] r 249 249 ··· 423 423 Alcotest.test_case "spec: empty data fields" `Quick 424 424 test_spec_example_empty_data; 425 425 Alcotest.test_case "spec: no trailing newline" `Quick 426 - test_spec_example_no_trailing_newline; 426 + test_spec_no_trailing_nl; 427 427 Alcotest.test_case "spec: with trailing newline" `Quick 428 - test_spec_example_with_trailing_newline; 428 + test_spec_with_trailing_nl; 429 429 (* Named events *) 430 430 Alcotest.test_case "named event" `Quick test_named_event; 431 431 Alcotest.test_case "event type resets" `Quick 432 - test_event_type_resets_after_dispatch; 432 + test_event_type_resets; 433 433 Alcotest.test_case "event type without data" `Quick 434 434 test_event_type_without_data; 435 435 (* ID field *) ··· 457 457 (* Field parsing *) 458 458 Alcotest.test_case "space stripping" `Quick test_space_stripping; 459 459 Alcotest.test_case "double space" `Quick 460 - test_double_space_only_one_stripped; 460 + test_double_space_strip; 461 461 Alcotest.test_case "no space after colon" `Quick test_no_space_after_colon; 462 462 Alcotest.test_case "unknown field" `Quick test_unknown_field_ignored; 463 463 Alcotest.test_case "field no colon" `Quick test_field_no_colon; 464 - Alcotest.test_case "colon in value" `Quick test_data_with_colon_in_value; 464 + Alcotest.test_case "colon in value" `Quick test_data_colon_value; 465 465 (* Line endings *) 466 466 Alcotest.test_case "LF" `Quick test_lf_line_endings; 467 467 Alcotest.test_case "CR" `Quick test_cr_line_endings; ··· 473 473 (* Incremental *) 474 474 Alcotest.test_case "split across chunks" `Quick test_split_across_chunks; 475 475 Alcotest.test_case "split at blank line" `Quick 476 - test_event_split_at_blank_line; 476 + test_event_split_blank; 477 477 Alcotest.test_case "CRLF split" `Quick test_crlf_split_across_chunks; 478 478 Alcotest.test_case "empty chunks" `Quick test_empty_chunks; 479 479 Alcotest.test_case "byte at a time" `Quick test_byte_at_a_time;