analytics/test/workers/notify_exported_analytics_test.exs

33 lines
906 B
Elixir
Raw Normal View History

defmodule Plausible.Workers.NotifyExportedAnalyticsTest do
use Plausible
use Plausible.DataCase
use Bamboo.Test
describe "perform/1" do
setup do
user = insert(:user)
site = insert(:site, members: [user])
{:ok, user: user, site: site}
end
# for 'success' case please see Plausible.Imported.CSVImporterTest
test "delivers 'failure' email", %{user: user, site: site} do
job =
Plausible.Workers.NotifyExportedAnalytics.new(%{
"status" => "failure",
"storage" => on_ee(do: "s3", else: "local"),
"email_to" => user.email,
"site_id" => site.id
})
Oban.insert!(job)
assert %{success: 1} =
Oban.drain_queue(queue: :notify_exported_analytics, with_safety: false)
assert_receive {:delivered_email, email}
assert email.html_body =~ "was unsuccessful."
end
end
end