Something went wrong. Try again.
A local Git merge queue with content-bound gate verdicts
Something went wrong. Try again.
2.1 kB · 55 lines
OCaml
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556(* mq web's follow of a repository whose queue is not set up yet (doc/web.md, "Live updates"): it answers why, then reads the queue again once mq init sets it up, on the kernel's report of the move and on no clock. *)
open Merge_queue_eiomodule M = Merge_queuemodule Command_web = Merge_queue_web_command.Command_web
let ok what = function | Ok x -> x | Error o -> Alcotest.failf "%s: %s" what (M.Outcome.first_line o)
(* A follower that slept a tick and looked again would hold a timer once it said why it could not read the queue, and would read the queue mq init set up only once the clock moved, which it never does here. *)let test_follow_set_up () = Fixture.with_dir @@ fun env root -> let src = Fpath.(root / "src") in Fixture.init env src; ignore (Fixture.commit env ~dir:src [ ("README", "ttl\n") ] "ttl"); let mono = Eio_mock.Clock.Mono.make () in let ctx = Fixture.context env src in let ctx = { ctx with clock = Clock.v (Eio_mock.Clock.make ()) mono } in let source = Command_web.source ctx in let refused, refuse = Eio.Promise.create () in let read, give = Eio.Promise.create () in Eio.Fiber.first (fun () -> source.follow src (function | Error why -> ignore (Eio.Promise.try_resolve refuse why) | Ok _ -> ignore (Eio.Promise.try_resolve give ()))) (fun () -> let why = Eio.Promise.await refused in Alcotest.(check string) "the queue not set up says why" "refused: mq init has not run in this repository" why; Alcotest.(check bool) "no reading yet" false (Eio.Promise.is_resolved read); for _ = 1 to 100 do Eio.Fiber.yield () done; Alcotest.(check bool) "the follower holds no timer" false (Eio_mock.Clock.Mono.try_advance mono); ignore (ok "mq init" (Command_init.run ctx ~url:None)); Eio.Promise.await read)
let suite = ( "command_web", [ Alcotest.test_case "a queue set up later is followed on no clock" `Quick test_follow_set_up; ] )