Something went wrong. Try again.
GitHub GraphQL client whose answers are kept in a raw store
Something went wrong. Try again.
1.5 kB · 44 lines
OCaml
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445open Alcobarmodule T = Github_query.Template
(* Normalising twice is normalising once, whatever the text. *)let test_normalise_idempotent s = let n = T.normalise s in check_eq ~pp:Fmt.string n (T.normalise n)
(* A quoted string is one string token: normalising leaves it as is. *)let test_quote s = let q = T.quote s in check_eq ~pp:Fmt.string q (T.normalise q)
(* Any JSON is a probed repository or not, without raising. *)let test_probe_of_json s = match Json.Value.of_string s with | Error _ -> () | Ok j -> ignore (Github_query.Probe.of_json j)
(* Any Link header value parses without raising, and its next page is one of its targets. *)let test_links s = let links = Github_query.Rest.links s in match Github_query.Rest.next_page s with | None -> () | Some u -> if not (List.mem_assoc u links) then fail "next is not a target"
(* A target written in GitHub's form is read back as the next page. *)let test_next_page u = if not (String.contains u '>') then check_eq ~pp:Fmt.(option string) (Some u) (Fmt.kstr Github_query.Rest.next_page "<%s>; rel=\"next\"" u)
let suite = ( "github_query", [ test_case "normalise is idempotent" [ bytes ] test_normalise_idempotent; test_case "quote is one token" [ bytes ] test_quote; test_case "probe of any JSON" [ bytes ] test_probe_of_json; test_case "links of any header" [ bytes ] test_links; test_case "next page read back" [ bytes ] test_next_page; ] )