Something went wrong. Try again.
A local Git merge queue with content-bound gate verdicts
Something went wrong. Try again.
1.3 kB · 39 lines
OCaml
at main
12345678910111213141516171819202122232425262728293031323334353637383940open Merge_queue
(* The empty tree, as git hash-object -t tree /dev/null names it. *)let hex = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"let tree = Option.get (Tree.of_hex hex)
let test_hex () = Alcotest.(check string) "to_hex" hex (Tree.to_hex tree); Alcotest.(check string) "pp" hex (Fmt.str "%a" Tree.pp tree); Alcotest.(check string) "the hash" hex (Git.Hash.to_hex (tree :> Git.Hash.t)); Alcotest.(check bool) "of_hash" true (Tree.equal tree (Tree.of_hash (Git.Hash.of_hex hex)))
let test_refused () = let none s = Alcotest.(check bool) s true (Option.is_none (Tree.of_hex s)) in none ""; none "4b825dc642cb"; none "4b825dc642cb6eb9a060e54bf8d69288fbee490g"
let test_short () = Alcotest.(check string) "short" "4b825dc642cb" (Tree.short tree)
let test_order () = let other = Option.get (Tree.of_hex "ffffffffffffffffffffffffffffffffffffffff") in Alcotest.(check bool) "equal" true (Tree.equal tree tree); Alcotest.(check bool) "not equal" false (Tree.equal tree other); Alcotest.(check bool) "compare" true (Tree.compare tree other < 0)
let suite = ( "tree", [ Alcotest.test_case "hexadecimal" `Quick test_hex; Alcotest.test_case "not an id" `Quick test_refused; Alcotest.test_case "short" `Quick test_short; Alcotest.test_case "order" `Quick test_order; ] )