diff --git a/alerting/provider/pagerduty/pagerduty_test.go b/alerting/provider/pagerduty/pagerduty_test.go index e4488be7..035d63af 100644 --- a/alerting/provider/pagerduty/pagerduty_test.go +++ b/alerting/provider/pagerduty/pagerduty_test.go @@ -2,6 +2,7 @@ package pagerduty import ( "github.com/TwinProduction/gatus/core" + "strings" "testing" ) @@ -16,10 +17,24 @@ func TestAlertProvider_IsValid(t *testing.T) { } } -func TestAlertProvider_ToCustomAlertProvider(t *testing.T) { +func TestAlertProvider_ToCustomAlertProviderWithResolvedAlert(t *testing.T) { provider := AlertProvider{IntegrationKey: "00000000000000000000000000000000"} customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, true) if customAlertProvider == nil { t.Error("customAlertProvider shouldn't have been nil") } + if !strings.Contains(customAlertProvider.Body, "RESOLVED") { + t.Error("customAlertProvider.Body should've contained the substring RESOLVED") + } +} + +func TestAlertProvider_ToCustomAlertProviderWithTriggeredAlert(t *testing.T) { + provider := AlertProvider{IntegrationKey: "00000000000000000000000000000000"} + customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, false) + if customAlertProvider == nil { + t.Error("customAlertProvider shouldn't have been nil") + } + if !strings.Contains(customAlertProvider.Body, "TRIGGERED") { + t.Error("customAlertProvider.Body should've contained the substring TRIGGERED") + } } diff --git a/alerting/provider/twilio/twilio_test.go b/alerting/provider/twilio/twilio_test.go index 0bf9c11c..8045c8c9 100644 --- a/alerting/provider/twilio/twilio_test.go +++ b/alerting/provider/twilio/twilio_test.go @@ -2,6 +2,7 @@ package twilio import ( "github.com/TwinProduction/gatus/core" + "strings" "testing" ) @@ -21,7 +22,7 @@ func TestTwilioAlertProvider_IsValid(t *testing.T) { } } -func TestAlertProvider_ToCustomAlertProvider(t *testing.T) { +func TestAlertProvider_ToCustomAlertProviderWithResolvedAlert(t *testing.T) { provider := AlertProvider{ SID: "1", Token: "1", @@ -32,4 +33,23 @@ func TestAlertProvider_ToCustomAlertProvider(t *testing.T) { if customAlertProvider == nil { t.Error("customAlertProvider shouldn't have been nil") } + if !strings.Contains(customAlertProvider.Body, "RESOLVED") { + t.Error("customAlertProvider.Body should've contained the substring RESOLVED") + } +} + +func TestAlertProvider_ToCustomAlertProviderWithTriggeredAlert(t *testing.T) { + provider := AlertProvider{ + SID: "1", + Token: "1", + From: "1", + To: "1", + } + customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, false) + if customAlertProvider == nil { + t.Error("customAlertProvider shouldn't have been nil") + } + if !strings.Contains(customAlertProvider.Body, "TRIGGERED") { + t.Error("customAlertProvider.Body should've contained the substring TRIGGERED") + } }