Hey, I got stuck with testing Repo.stream
with Task.async_stream and exunit
Example code:
Repo.transaction(fn ->
Repo.stream(Schema)
|> Task.async_stream(Heavy, :io_to_ecto, [], [])
|> Stream.run
end)
And test for it:
test "io/0" do
stream_transaction()
assert length(Repo.all(SchemaTest) == 1500
end
And the error
[error] Postgrex.Protocol (#PID<0.361.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.494.0> exited while client #PID<0.499.0> is still running with: shutdown
I understand why we have such an error, but still looking for some way to write proper unit test for my case.
Any ideas?