Is it considered bad practice to have parent_pid
argument on most handlecast and handleinfo functions in production ?
I am testing like this:
parent = self()
GenServer.cast(UserServer.via_tuple(user.id), {:update_direct, parent})
assert_receive :updating_failed, 2000
And then genserver(with simple retry mock):
def handle_cast(..... parent) do
case updated do
false -> Process.send_after(self(), {:update_retry, ... parent, retries + 1}, 500)
true -> ...
state
end
end
And finally in handle_info :update_retry
I send message back to awaiting test(parent):
send parent, :updating_failed