livebook/test/support/app_helpers.ex
Jonatan Kłosko 8c91a1f788
Introduce abstraction for app deployment and permanent apps (#2524)
Co-authored-by: José Valim <jose.valim@dashbit.co>
2024-03-26 20:20:07 +01:00

22 lines
535 B
Elixir

defmodule Livebook.AppHelpers do
def deploy_notebook_sync(notebook) do
app_spec = Livebook.Apps.NotebookAppSpec.new(notebook)
deployer_pid = Livebook.Apps.Deployer.local_deployer()
ref = Livebook.Apps.Deployer.deploy_monitor(deployer_pid, app_spec)
receive do
{:deploy_result, ^ref, {:ok, pid}} ->
Process.demonitor(ref, [:flush])
ExUnit.Callbacks.on_exit(fn ->
if Process.alive?(pid) do
Livebook.App.close(pid)
end
end)
pid
end
end
end