diff --git a/alerting/provider/custom/custom_test.go b/alerting/provider/custom/custom_test.go index 92f8c5ba..e1906e44 100644 --- a/alerting/provider/custom/custom_test.go +++ b/alerting/provider/custom/custom_test.go @@ -1,6 +1,7 @@ package custom import ( + "github.com/TwinProduction/gatus/core" "io/ioutil" "testing" ) @@ -57,3 +58,14 @@ func TestAlertProvider_buildRequestWhenTriggered(t *testing.T) { t.Error("expected body to be", ExpectedBody, "was", string(body)) } } + +func TestAlertProvider_ToCustomAlertProvider(t *testing.T) { + provider := AlertProvider{Url: "http://example.com"} + customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, true) + if customAlertProvider == nil { + t.Error("customAlertProvider shouldn't have been nil") + } + if customAlertProvider != customAlertProvider { + t.Error("customAlertProvider should've been equal to customAlertProvider") + } +} diff --git a/alerting/provider/pagerduty/pagerduty_test.go b/alerting/provider/pagerduty/pagerduty_test.go index 47765d3f..e4488be7 100644 --- a/alerting/provider/pagerduty/pagerduty_test.go +++ b/alerting/provider/pagerduty/pagerduty_test.go @@ -1,6 +1,9 @@ package pagerduty -import "testing" +import ( + "github.com/TwinProduction/gatus/core" + "testing" +) func TestAlertProvider_IsValid(t *testing.T) { invalidProvider := AlertProvider{IntegrationKey: ""} @@ -12,3 +15,11 @@ func TestAlertProvider_IsValid(t *testing.T) { t.Error("provider should've been valid") } } + +func TestAlertProvider_ToCustomAlertProvider(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") + } +} diff --git a/alerting/provider/slack/slack_test.go b/alerting/provider/slack/slack_test.go index 0a9af3e0..1715376a 100644 --- a/alerting/provider/slack/slack_test.go +++ b/alerting/provider/slack/slack_test.go @@ -1,6 +1,9 @@ package slack -import "testing" +import ( + "github.com/TwinProduction/gatus/core" + "testing" +) func TestAlertProvider_IsValid(t *testing.T) { invalidProvider := AlertProvider{WebhookUrl: ""} @@ -12,3 +15,11 @@ func TestAlertProvider_IsValid(t *testing.T) { t.Error("provider should've been valid") } } + +func TestAlertProvider_ToCustomAlertProvider(t *testing.T) { + provider := AlertProvider{WebhookUrl: "http://example.com"} + customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, true) + if customAlertProvider == nil { + t.Error("customAlertProvider shouldn't have been nil") + } +} diff --git a/alerting/provider/twilio/twilio_test.go b/alerting/provider/twilio/twilio_test.go index c3613b97..0bf9c11c 100644 --- a/alerting/provider/twilio/twilio_test.go +++ b/alerting/provider/twilio/twilio_test.go @@ -1,6 +1,9 @@ package twilio -import "testing" +import ( + "github.com/TwinProduction/gatus/core" + "testing" +) func TestTwilioAlertProvider_IsValid(t *testing.T) { invalidProvider := AlertProvider{} @@ -17,3 +20,16 @@ func TestTwilioAlertProvider_IsValid(t *testing.T) { t.Error("provider should've been valid") } } + +func TestAlertProvider_ToCustomAlertProvider(t *testing.T) { + provider := AlertProvider{ + SID: "1", + Token: "1", + From: "1", + To: "1", + } + customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, true) + if customAlertProvider == nil { + t.Error("customAlertProvider shouldn't have been nil") + } +}