Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrikstrid committed May 4, 2020
1 parent 083c13f commit 95592ac
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
5 changes: 1 addition & 4 deletions lib_test/Helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ let check_option_string = Alcotest.(check (option string))

let check_int = Alcotest.(check int)


let opt_of_result = function
| Ok v -> Some v
| _ -> None
let opt_of_result = function Ok v -> Some v | _ -> None

let hd_safe ~default l = try Base.List.hd_exn l with Failure _ -> default
39 changes: 26 additions & 13 deletions lib_test/test_date.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,55 +28,68 @@ let tests =
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Mon, 06 Jan 2020 08:04:19 UTC" in
check_result_string expected (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Tue, 11 Feb 2020 09:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Wed, 25 Mar 2020 10:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Thu, 02 Apr 2020 11:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Fri, 01 May 2020 12:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Sat, 27 Jun 2020 13:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Sun, 12 Jul 2020 14:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Mon, 31 Aug 2020 15:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Tue, 22 Sep 2020 16:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Wed, 07 Oct 2020 17:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Thu, 19 Nov 2020 18:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Fri, 25 Dec 2020 19:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
Alcotest.test_case "serialize" `Quick (fun () ->
let expected = "Mon, 16 Nov 2020 08:04:19 UTC" in
check_result_string "" (Ok expected)
(Base.Result.map ~f:Cookie.Date.serialize (Cookie.Date.parse expected)));
(Base.Result.map ~f:Cookie.Date.serialize
(Cookie.Date.parse expected)));
] )

let suite, _ =
Expand Down
9 changes: 5 additions & 4 deletions lib_test/test_http_state.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ let tests =
if key = "Set-Cookie" then Some (key, value) else None)
test_headers
|> Base.List.filter_map
~f:(Cookie.of_set_cookie_header ~origin:"home.example.org")
~f:
(Cookie.of_set_cookie_header ~origin:"home.example.org")
in
let now =
Base.Option.( Cookie.Date.parse "Wen, 28 Feb 2018 08:04:19 GMT"
|> opt_of_result
>>= Ptime.of_date_time )
Base.Option.(
Cookie.Date.parse "Wen, 28 Feb 2018 08:04:19 GMT"
|> opt_of_result >>= Ptime.of_date_time)
in
let test =
set_cookie_headers |> Cookie.to_cookie_header ?now ~scope
Expand Down

0 comments on commit 95592ac

Please sign in to comment.