Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849"""Fresh spare adoption restores a namespace through the daemon's real link stack."""
from pathlib import Pathimport unittest
from harness import Albedo, exclusivefrom inspect_support import Inspectionfrom kernel_support import editable_daemon
@exclusiveclass KernelSpareTests(unittest.TestCase): def test_unused_spares_end_on_stop_and_owner_death(self): with Albedo(prepare=lambda app: app.env.update(ALBEDO_INSPECT="1")) as app: probe = Inspection( app, Path(__file__).with_name("albedo_kernel_spare_probe.erl") ) self.assertTrue(probe.call_json("stop_json")["stopped"])
def test_stale_spare_is_cleaned_before_cold_fallback(self): def prepare(app): launcher, app.bundle = editable_daemon(app.root) app.env.update(ALBEDO_INSPECT="1", ALBEDO_DAEMON=str(launcher))
with Albedo(prepare=prepare) as app: session = app.session() probe = Inspection( app, Path(__file__).with_name("albedo_kernel_spare_probe.erl") ) changed = app.bundle / "albedo_bundle.py" result = probe.call_json( "run_json", f'[<<"{session}">>, <<"{app.workspace}">>, <<"{changed}">>]' ) self.assertEqual(result["recalled"]["status"], "ok", result) self.assertIn("SPARE_OK", result["recalled"]["output"])
def test_spare_is_single_use_and_restores_definitions(self): with Albedo(prepare=lambda app: app.env.update(ALBEDO_INSPECT="1")) as app: session = app.session() probe = Inspection( app, Path(__file__).with_name("albedo_kernel_spare_probe.erl") ) result = probe.call_json( "run_json", f'[<<"{session}">>, <<"{app.workspace}">>, <<>>]' ) self.assertEqual(result["recalled"]["status"], "ok", result) self.assertIn("SPARE_OK", result["recalled"]["output"]) self.assertEqual(result["live_work"], 0)