okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
b585313
main
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 { 8let pid = process . spawn ( fn () { Nil }) 9turn . Run ( id , pid , process . monitor ( pid ), False , turn . latch (), work ) 10} 11 12fn running ( id : String ) -> turn . Activity { 13turn . Running ( run ( id , turn . Turn ( None ))) 14} 15 16pub fn late_messages_from_an_old_run_are_not_owned_test () -> Nil { 17let activity = running ( "current" ) 18turn . owner ( activity , "old" ) |> should . equal ( None ) 19turn . live ( activity , "old" ) |> should . be_false 20turn . live ( activity , "current" ) |> should . be_true 21turn . 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 { 27let activity = turn . cancel ( running ( "a" )) 28turn . live ( activity , "a" ) |> should . be_false 29let assert Some ( owned ) = turn . owner ( activity , "a" ) 30owned . cancelled |> should . be_true 31turn . cancel ( turn . Resting ) |> should . equal ( turn . Resting ) 32}