swoosh
swoosh copied to clipboard
Swoosh.TestAssertions do not account for deliver_many.
Working in my own side project today I was trying to use assert_email_sent after a deliver_many call. I don't think this is working. Might be doing it wrong. Not sure. My current test is something like this:
describe "send_email_notification_batch/1" do
setup [:with_various_delivery_status]
test "success: emails we sent", %{group: group} do
notes = Notifications.list_email_notifications_ready_for_delivery(prefix: group.subdomain)
{:ok, _} = Notifications.send_email_notification_batch(prefix: group.subdomain)
for note <- notes do
assert_email_sent(Guildflow.NewMessageEmailNotification.new(note))
end
end
end
And the failure is a bad match:
Poking around the code I'm not sure Swoosh.TestAssertions ever expect that kind of message.
Right. Currently Swoosh.TestAssertions is not equipped with the necessary tools to deal with deliver_many. As a workaround you can just go assert_receive until something like assert_emails_sent is added. Note, deliver_many will not behave like multiple calls to deliver, it is meant to be different.
Can I work on that? :eyes:
Yeah. https://github.com/swoosh/swoosh/pull/721 take this into consideration, though.
Okay.