swoosh icon indicating copy to clipboard operation
swoosh copied to clipboard

Swoosh.TestAssertions do not account for deliver_many.

Open zorn opened this issue 4 years ago • 1 comments
trafficstars

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:

Screen Shot 2021-01-09 at 6 04 11 PM

Poking around the code I'm not sure Swoosh.TestAssertions ever expect that kind of message.

zorn avatar Jan 09 '21 23:01 zorn

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.

princemaple avatar Jan 10 '21 00:01 princemaple

Can I work on that? :eyes:

geeksilva97 avatar Oct 22 '22 14:10 geeksilva97

Yeah. https://github.com/swoosh/swoosh/pull/721 take this into consideration, though.

princemaple avatar Oct 22 '22 15:10 princemaple

Okay.

geeksilva97 avatar Oct 24 '22 18:10 geeksilva97