-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d65444
commit 1b30176
Showing
1 changed file
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
defmodule Trento.Application.UseCases.AlertingTest do | ||
@moduledoc false | ||
use ExUnit.Case, async: true | ||
use Trento.DataCase | ||
|
||
|
@@ -10,12 +11,16 @@ defmodule Trento.Application.UseCases.AlertingTest do | |
|
||
@moduletag :integration | ||
|
||
@some_sender "[email protected]" | ||
@some_recipient "[email protected]" | ||
|
||
describe "Enabling/Disabling Alerting Feature" do | ||
setup do | ||
on_exit(fn -> | ||
Application.put_env(:trento, :alerting, | ||
enabled: true, | ||
recipient: "[email protected]" | ||
sender: @some_sender, | ||
recipient: @some_recipient | ||
) | ||
end) | ||
end | ||
|
@@ -30,7 +35,12 @@ defmodule Trento.Application.UseCases.AlertingTest do | |
end | ||
|
||
test "An error should be raised when alerting is enabled but no recipient was provided" do | ||
Application.put_env(:trento, :alerting, enabled: true) | ||
Application.put_env(:trento, :alerting, | ||
enabled: true, | ||
sender: @some_sender | ||
# no recipient set | ||
) | ||
|
||
sap_system_id = Faker.UUID.v4() | ||
insert(:sap_system, id: sap_system_id) | ||
|
||
|
@@ -40,6 +50,23 @@ defmodule Trento.Application.UseCases.AlertingTest do | |
|
||
assert_no_email_sent() | ||
end | ||
|
||
test "An error should be raised when alerting is enabled but no sender was provided" do | ||
Application.put_env(:trento, :alerting, | ||
enabled: true, | ||
# no sender set | ||
recipient: @some_recipient | ||
) | ||
|
||
sap_system_id = Faker.UUID.v4() | ||
insert(:sap_system, id: sap_system_id) | ||
|
||
assert_raise ArgumentError, | ||
~r/Unexpected tuple format, {"Trento Alerts", nil} cannot be formatted into a Recipient./, | ||
fn -> Alerting.notify_critical_sap_system_health(sap_system_id) end | ||
|
||
assert_no_email_sent() | ||
end | ||
end | ||
|
||
describe "Alerting the configured recipient about crucial facts with email notifications" do | ||
|