Hello, I have a function that uses Repo.stream
and Task.async_stream
, but in ExUnit
every time I have a different result and I can not wait for this function output
def delete_plugins(event) do
stream = MishkaDatabase.Repo.stream(from(plg in PluginSchema))
MishkaDatabase.Repo.transaction(fn() ->
stream
|> Stream.filter(&(event in &1.depends))
|> Enum.to_list()
end)
|> case do
{:ok, list} ->
list
|> Task.async_stream(&MishkaInstaller.Hook.unregister(module: &1.name), max_concurrency: 20)
|> Stream.run
error ->
IO.inspect(error)
end
end
for example:
test "test 1" do
Plugin.delete_plugins("test"))
assert_receive :ok, 30_000
end
when I run top test block code, I receive this error
Assertion failed, no matching message after 30000ms
The process mailbox is empty.
When I print Plugin.delete_plugins("test"))
it shows me :ok:, but
assert_receive` cannot get it.
Thank you