okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

Aly Raffaufrefactor(gleam): clean up code and enforce focused lint checksb585313

main
1.1 KiB32 linesraw
1/// Late and cancelled run ownership cannot be reliably scheduled in E2E.
2import albedo/daemon/turn
3import gleam/erlang/process
4import gleam/option.{None, Some}
5import gleeunit/should
6
7fn run(id: String, work: turn.Work) -> turn.Run {
8  let pid = process.spawn(fn() { Nil })
9  turn.Run(id, pid, process.monitor(pid), False, turn.latch(), work)
10}
11
12fn running(id: String) -> turn.Activity {
13  turn.Running(run(id, turn.Turn(None)))
14}
15
16pub fn late_messages_from_an_old_run_are_not_owned_test() -> Nil {
17  let activity = running("current")
18  turn.owner(activity, "old") |> should.equal(None)
19  turn.live(activity, "old") |> should.be_false
20  turn.live(activity, "current") |> should.be_true
21  turn.owner(turn.Resting, "current") |> should.equal(None)
22}
23
24// A cancelled run may still save completed tool results but may not publish
25// or take queued input.
26pub fn cancelled_run_still_owns_writes_but_is_not_live_test() -> Nil {
27  let activity = turn.cancel(running("a"))
28  turn.live(activity, "a") |> should.be_false
29  let assert Some(owned) = turn.owner(activity, "a")
30  owned.cancelled |> should.be_true
31  turn.cancel(turn.Resting) |> should.equal(turn.Resting)
32}