I have a GenStage producer_consumer that I’d like to test in isolation and I’m not sure where to start. I tried building a Flow to pipe in a known input and see what output I get, but it hangs for some reason:
test "returns results" do
{:ok, message_builder} = MessageBuilder.start_link
{:ok, phase_1} =
[%{body: "test"}]
|> Flow.from_enumerable
|> Flow.into_stages([message_builder])
result =
phase_1
|> Flow.from_stage
|> Enum.to_list
assert length(result) == 1
end
I’m also considering testing the handle_events
function directly, but that seems like I shouldn’t be testing a private api. What is the best way to approach this?