okami.mom/albedo

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

nekomimi.petfix(daemon): a slow store no longer crashes waiting sessions; image release scans once1b24e0e

main
762 B23 linesraw
1//// A store query waits for its answer with no deadline, so a store that stops
2//// must end the wait at once. A daemon run never stops its store under a
3//// waiting caller, so only this test sees a hang there.
4
5import albedo/daemon/store
6import gleam/erlang/process
7
8pub fn a_query_on_a_stopped_store_fails_at_once_test() -> Nil {
9  let assert Ok(db) = store.start(":memory:", "")
10  store.close(db)
11  let caller =
12    process.spawn_unlinked(fn() {
13      store.query(db, fn(_) { Nil })
14      Nil
15    })
16  let monitor = process.monitor(caller)
17  let assert Ok(_) =
18    process.new_selector()
19    |> process.select_specific_monitor(monitor, fn(down) { down })
20    |> process.selector_receive(1000)
21    as "the caller is still waiting on a stopped store"
22  Nil
23}