How to mock response for cohttp?

I wanna to write some unit tests for the process of http response, for example, for this function

let get_em_positions_resp ~code ~year ~month =
  let%bind _, body =
      ~headers:(Cohttp.Header.of_list [ (hdr_ua, ua) ])
      (generate_em_positions_uri ~code ~year ~month)
  Cohttp_async.Body.to_string body

When I wrote Java, there’s some cool thing to help. Is there kind of mock tools in OCaml?

1 Like

You might want to implement Cohttp_lwt.S.Client like I did in there:

1 Like