47 lines
1.2 KiB
OCaml
47 lines
1.2 KiB
OCaml
|
|
let thread_w_reply_to_simple v =
|
||
|
|
let open Types in
|
||
|
|
let Thread_w_reply.
|
||
|
|
{ op; subject; lat; lng; bump_status; reply_count; reply_l = _ } =
|
||
|
|
v
|
||
|
|
in
|
||
|
|
let thread = { op; subject; lat; lng; bump_status; reply_count } in
|
||
|
|
thread
|
||
|
|
|
||
|
|
(* -- image data -- *)
|
||
|
|
let imgs =
|
||
|
|
let mk_img =
|
||
|
|
let load path =
|
||
|
|
match Assets.read path with
|
||
|
|
| None -> Fmt.failwith "test image `%s` not found" path
|
||
|
|
| Some o -> o
|
||
|
|
in
|
||
|
|
fun kind ->
|
||
|
|
let data = load (Fmt.str "/fff.%s" kind) in
|
||
|
|
let mime =
|
||
|
|
Fmt.str "image/%s" (if kind = "exif.png" then "png" else kind)
|
||
|
|
in
|
||
|
|
(mime, Fmt.str "fff.%s" kind, Fmt.str "a 1px %s test image" kind, data)
|
||
|
|
in
|
||
|
|
Array.map mk_img [| "png"; "jpeg"; "gif"; "exif.png" |]
|
||
|
|
|
||
|
|
(* -- alcotest util -- *)
|
||
|
|
|
||
|
|
let err = Alcotest.testable Err.pp ( = )
|
||
|
|
|
||
|
|
let result ok_testable = Alcotest.result ok_testable err
|
||
|
|
|
||
|
|
let unit_result = result Alcotest.unit
|
||
|
|
|
||
|
|
let error msg = Error (Err.Unprocessable msg)
|
||
|
|
|
||
|
|
let assert_error res =
|
||
|
|
match res with Ok _ -> error "assert_error failure" | Error _ -> Ok ()
|
||
|
|
|
||
|
|
let assert_true b =
|
||
|
|
match b with true -> Ok () | false -> error "assert_true failure"
|
||
|
|
|
||
|
|
let option_get opt =
|
||
|
|
match opt with
|
||
|
|
| Some v -> Ok v
|
||
|
|
| None -> error "option_get failure, option is none"
|