From 08742e4af31fd5a7b9daf14b4b160918b1db7c08 Mon Sep 17 00:00:00 2001 From: TwiN Date: Wed, 7 Feb 2024 20:09:45 -0500 Subject: [PATCH] refactor(alerting): Use pointer for receiver in AlertProvider.GetDefaultAlert method (#676) --- alerting/provider/awsses/awsses.go | 5 +++-- alerting/provider/awsses/awsses_test.go | 4 ++-- alerting/provider/custom/custom.go | 2 +- alerting/provider/custom/custom_test.go | 4 ++-- alerting/provider/discord/discord.go | 2 +- alerting/provider/discord/discord_test.go | 4 ++-- alerting/provider/email/email.go | 2 +- alerting/provider/email/email_test.go | 4 ++-- alerting/provider/github/github.go | 2 +- alerting/provider/github/github_test.go | 4 ++-- alerting/provider/gitlab/gitlab.go | 2 +- alerting/provider/gitlab/gitlab_test.go | 4 ++-- alerting/provider/googlechat/googlechat.go | 2 +- alerting/provider/googlechat/googlechat_test.go | 4 ++-- alerting/provider/gotify/gotify.go | 2 +- alerting/provider/matrix/matrix.go | 2 +- alerting/provider/matrix/matrix_test.go | 4 ++-- alerting/provider/mattermost/mattermost.go | 2 +- alerting/provider/mattermost/mattermost_test.go | 4 ++-- alerting/provider/messagebird/messagebird.go | 2 +- alerting/provider/messagebird/messagebird_test.go | 4 ++-- alerting/provider/ntfy/ntfy.go | 2 +- alerting/provider/opsgenie/opsgenie.go | 2 +- alerting/provider/pagerduty/pagerduty.go | 2 +- alerting/provider/pagerduty/pagerduty_test.go | 4 ++-- alerting/provider/pushover/pushover.go | 2 +- alerting/provider/pushover/pushover_test.go | 4 ++-- alerting/provider/slack/slack.go | 2 +- alerting/provider/slack/slack_test.go | 4 ++-- alerting/provider/teams/teams.go | 2 +- alerting/provider/teams/teams_test.go | 4 ++-- alerting/provider/telegram/telegram.go | 2 +- alerting/provider/telegram/telegram_test.go | 4 ++-- alerting/provider/twilio/twilio.go | 2 +- alerting/provider/twilio/twilio_test.go | 4 ++-- 35 files changed, 53 insertions(+), 52 deletions(-) diff --git a/alerting/provider/awsses/awsses.go b/alerting/provider/awsses/awsses.go index a5abee99..a63db30d 100644 --- a/alerting/provider/awsses/awsses.go +++ b/alerting/provider/awsses/awsses.go @@ -2,6 +2,8 @@ package awsses import ( "fmt" + "strings" + "github.com/TwiN/gatus/v5/alerting/alert" "github.com/TwiN/gatus/v5/core" "github.com/aws/aws-sdk-go/aws" @@ -9,7 +11,6 @@ import ( "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ses" - "strings" ) const ( @@ -148,7 +149,7 @@ func (provider *AlertProvider) getToForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/awsses/awsses_test.go b/alerting/provider/awsses/awsses_test.go index 08c138a4..d13022b1 100644 --- a/alerting/provider/awsses/awsses_test.go +++ b/alerting/provider/awsses/awsses_test.go @@ -116,10 +116,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/custom/custom.go b/alerting/provider/custom/custom.go index ffc5105c..052af1ab 100644 --- a/alerting/provider/custom/custom.go +++ b/alerting/provider/custom/custom.go @@ -93,6 +93,6 @@ func (provider *AlertProvider) Send(endpoint *core.Endpoint, alert *alert.Alert, } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/custom/custom_test.go b/alerting/provider/custom/custom_test.go index 375f9d48..3927bb6c 100644 --- a/alerting/provider/custom/custom_test.go +++ b/alerting/provider/custom/custom_test.go @@ -217,10 +217,10 @@ func TestAlertProvider_GetAlertStatePlaceholderValueDefaults(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/discord/discord.go b/alerting/provider/discord/discord.go index 21be934a..0696a610 100644 --- a/alerting/provider/discord/discord.go +++ b/alerting/provider/discord/discord.go @@ -145,6 +145,6 @@ func (provider *AlertProvider) getWebhookURLForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/discord/discord_test.go b/alerting/provider/discord/discord_test.go index 3d4374ab..bb69cd83 100644 --- a/alerting/provider/discord/discord_test.go +++ b/alerting/provider/discord/discord_test.go @@ -206,10 +206,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/email/email.go b/alerting/provider/email/email.go index 47940cae..67a6dea8 100644 --- a/alerting/provider/email/email.go +++ b/alerting/provider/email/email.go @@ -125,6 +125,6 @@ func (provider *AlertProvider) getToForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/email/email_test.go b/alerting/provider/email/email_test.go index 325432a3..4cab7134 100644 --- a/alerting/provider/email/email_test.go +++ b/alerting/provider/email/email_test.go @@ -118,10 +118,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/github/github.go b/alerting/provider/github/github.go index 4cec9ac0..fa25022c 100644 --- a/alerting/provider/github/github.go +++ b/alerting/provider/github/github.go @@ -124,6 +124,6 @@ func (provider *AlertProvider) buildIssueBody(endpoint *core.Endpoint, alert *al } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/github/github_test.go b/alerting/provider/github/github_test.go index 5972e269..c16e6f62 100644 --- a/alerting/provider/github/github_test.go +++ b/alerting/provider/github/github_test.go @@ -149,10 +149,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/gitlab/gitlab.go b/alerting/provider/gitlab/gitlab.go index ac7ad843..11d337ff 100644 --- a/alerting/provider/gitlab/gitlab.go +++ b/alerting/provider/gitlab/gitlab.go @@ -142,6 +142,6 @@ func (provider *AlertProvider) buildAlertBody(endpoint *core.Endpoint, alert *al } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/gitlab/gitlab_test.go b/alerting/provider/gitlab/gitlab_test.go index 0cb6edbd..8ea389fd 100644 --- a/alerting/provider/gitlab/gitlab_test.go +++ b/alerting/provider/gitlab/gitlab_test.go @@ -149,10 +149,10 @@ func TestAlertProvider_buildAlertBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/googlechat/googlechat.go b/alerting/provider/googlechat/googlechat.go index 0b2ec337..ea1b4b8c 100644 --- a/alerting/provider/googlechat/googlechat.go +++ b/alerting/provider/googlechat/googlechat.go @@ -196,6 +196,6 @@ func (provider *AlertProvider) getWebhookURLForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/googlechat/googlechat_test.go b/alerting/provider/googlechat/googlechat_test.go index d12592f3..7cd2c0a9 100644 --- a/alerting/provider/googlechat/googlechat_test.go +++ b/alerting/provider/googlechat/googlechat_test.go @@ -205,10 +205,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/gotify/gotify.go b/alerting/provider/gotify/gotify.go index e9b1d59b..e6e35a7c 100644 --- a/alerting/provider/gotify/gotify.go +++ b/alerting/provider/gotify/gotify.go @@ -100,6 +100,6 @@ func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert * } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/matrix/matrix.go b/alerting/provider/matrix/matrix.go index 749a9965..7a6ff17c 100644 --- a/alerting/provider/matrix/matrix.go +++ b/alerting/provider/matrix/matrix.go @@ -185,6 +185,6 @@ func randStringBytes(n int) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/matrix/matrix_test.go b/alerting/provider/matrix/matrix_test.go index d1c02a3c..00b6b131 100644 --- a/alerting/provider/matrix/matrix_test.go +++ b/alerting/provider/matrix/matrix_test.go @@ -219,10 +219,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/mattermost/mattermost.go b/alerting/provider/mattermost/mattermost.go index 79a1a733..c5fb9139 100644 --- a/alerting/provider/mattermost/mattermost.go +++ b/alerting/provider/mattermost/mattermost.go @@ -151,6 +151,6 @@ func (provider *AlertProvider) getWebhookURLForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/mattermost/mattermost_test.go b/alerting/provider/mattermost/mattermost_test.go index 2723d2fa..b543ce67 100644 --- a/alerting/provider/mattermost/mattermost_test.go +++ b/alerting/provider/mattermost/mattermost_test.go @@ -190,10 +190,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/messagebird/messagebird.go b/alerting/provider/messagebird/messagebird.go index 7c9c631c..eaf93937 100644 --- a/alerting/provider/messagebird/messagebird.go +++ b/alerting/provider/messagebird/messagebird.go @@ -76,6 +76,6 @@ func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert * } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/messagebird/messagebird_test.go b/alerting/provider/messagebird/messagebird_test.go index 47e56654..a5a7b3b2 100644 --- a/alerting/provider/messagebird/messagebird_test.go +++ b/alerting/provider/messagebird/messagebird_test.go @@ -153,10 +153,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/ntfy/ntfy.go b/alerting/provider/ntfy/ntfy.go index 4b1fe257..4036ea8a 100644 --- a/alerting/provider/ntfy/ntfy.go +++ b/alerting/provider/ntfy/ntfy.go @@ -110,6 +110,6 @@ func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert * } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/opsgenie/opsgenie.go b/alerting/provider/opsgenie/opsgenie.go index 5e018ee9..8d7f2a81 100644 --- a/alerting/provider/opsgenie/opsgenie.go +++ b/alerting/provider/opsgenie/opsgenie.go @@ -206,7 +206,7 @@ func (provider *AlertProvider) priority() string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/pagerduty/pagerduty.go b/alerting/provider/pagerduty/pagerduty.go index ea13d904..7dabb576 100644 --- a/alerting/provider/pagerduty/pagerduty.go +++ b/alerting/provider/pagerduty/pagerduty.go @@ -138,7 +138,7 @@ func (provider *AlertProvider) getIntegrationKeyForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/pagerduty/pagerduty_test.go b/alerting/provider/pagerduty/pagerduty_test.go index 2c7ab8d2..4523f280 100644 --- a/alerting/provider/pagerduty/pagerduty_test.go +++ b/alerting/provider/pagerduty/pagerduty_test.go @@ -237,10 +237,10 @@ func TestAlertProvider_getIntegrationKeyForGroup(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/pushover/pushover.go b/alerting/provider/pushover/pushover.go index f80b7eea..6b5343fd 100644 --- a/alerting/provider/pushover/pushover.go +++ b/alerting/provider/pushover/pushover.go @@ -107,6 +107,6 @@ func (provider *AlertProvider) priority() int { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/pushover/pushover_test.go b/alerting/provider/pushover/pushover_test.go index 5a5720f1..57f03fb5 100644 --- a/alerting/provider/pushover/pushover_test.go +++ b/alerting/provider/pushover/pushover_test.go @@ -172,10 +172,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/slack/slack.go b/alerting/provider/slack/slack.go index 5cf54eea..017257cc 100644 --- a/alerting/provider/slack/slack.go +++ b/alerting/provider/slack/slack.go @@ -137,6 +137,6 @@ func (provider *AlertProvider) getWebhookURLForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/slack/slack_test.go b/alerting/provider/slack/slack_test.go index 5471fc3b..cc218eca 100644 --- a/alerting/provider/slack/slack_test.go +++ b/alerting/provider/slack/slack_test.go @@ -205,10 +205,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/teams/teams.go b/alerting/provider/teams/teams.go index cd654d70..390e6aaf 100644 --- a/alerting/provider/teams/teams.go +++ b/alerting/provider/teams/teams.go @@ -130,6 +130,6 @@ func (provider *AlertProvider) getWebhookURLForGroup(group string) string { } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/teams/teams_test.go b/alerting/provider/teams/teams_test.go index 3cec8089..00df33d3 100644 --- a/alerting/provider/teams/teams_test.go +++ b/alerting/provider/teams/teams_test.go @@ -186,10 +186,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/telegram/telegram.go b/alerting/provider/telegram/telegram.go index 3a9d7ecb..7b2a357b 100644 --- a/alerting/provider/telegram/telegram.go +++ b/alerting/provider/telegram/telegram.go @@ -97,6 +97,6 @@ func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert * } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/telegram/telegram_test.go b/alerting/provider/telegram/telegram_test.go index fc93fda7..d3e0f900 100644 --- a/alerting/provider/telegram/telegram_test.go +++ b/alerting/provider/telegram/telegram_test.go @@ -159,10 +159,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } } diff --git a/alerting/provider/twilio/twilio.go b/alerting/provider/twilio/twilio.go index 7b927a73..8370a298 100644 --- a/alerting/provider/twilio/twilio.go +++ b/alerting/provider/twilio/twilio.go @@ -66,6 +66,6 @@ func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert * } // GetDefaultAlert returns the provider's default alert configuration -func (provider AlertProvider) GetDefaultAlert() *alert.Alert { +func (provider *AlertProvider) GetDefaultAlert() *alert.Alert { return provider.DefaultAlert } diff --git a/alerting/provider/twilio/twilio_test.go b/alerting/provider/twilio/twilio_test.go index 362c6d23..31328a2f 100644 --- a/alerting/provider/twilio/twilio_test.go +++ b/alerting/provider/twilio/twilio_test.go @@ -69,10 +69,10 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { } func TestAlertProvider_GetDefaultAlert(t *testing.T) { - if (AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { + if (&AlertProvider{DefaultAlert: &alert.Alert{}}).GetDefaultAlert() == nil { t.Error("expected default alert to be not nil") } - if (AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { + if (&AlertProvider{DefaultAlert: nil}).GetDefaultAlert() != nil { t.Error("expected default alert to be nil") } }