feat(alerting): Add Pushover provider (#405)
* Add a new Pushover provider (#129) - Adds new provider named Pushover with corresponding tests - Adds Pushover as a provider to the configuration and adjusts test accordingly - Adds Pushover to alerting_test.go, provider.go and type.go - Updates the readme with configuration details * Correct import order * Fix some missing pushover references * Apply suggestions from code review * Rename application-key to application-token for Pushover --------- Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
||||
"github.com/TwiN/gatus/v5/alerting/provider/mattermost"
|
||||
"github.com/TwiN/gatus/v5/alerting/provider/messagebird"
|
||||
"github.com/TwiN/gatus/v5/alerting/provider/pagerduty"
|
||||
"github.com/TwiN/gatus/v5/alerting/provider/pushover"
|
||||
"github.com/TwiN/gatus/v5/alerting/provider/slack"
|
||||
"github.com/TwiN/gatus/v5/alerting/provider/teams"
|
||||
"github.com/TwiN/gatus/v5/alerting/provider/telegram"
|
||||
@ -203,6 +204,42 @@ func TestHandleAlertingWhenTriggeredAlertIsResolvedPagerDuty(t *testing.T) {
|
||||
verify(t, endpoint, 0, 1, false, "The alert should've been resolved")
|
||||
}
|
||||
|
||||
func TestHandleAlertingWhenTriggeredAlertIsResolvedPushover(t *testing.T) {
|
||||
_ = os.Setenv("MOCK_ALERT_PROVIDER", "true")
|
||||
defer os.Clearenv()
|
||||
|
||||
cfg := &config.Config{
|
||||
Debug: true,
|
||||
Alerting: &alerting.Config{
|
||||
Pushover: &pushover.AlertProvider{
|
||||
ApplicationToken: "000000000000000000000000000000",
|
||||
UserKey: "000000000000000000000000000000",
|
||||
},
|
||||
},
|
||||
}
|
||||
enabled := true
|
||||
endpoint := &core.Endpoint{
|
||||
URL: "https://example.com",
|
||||
Alerts: []*alert.Alert{
|
||||
{
|
||||
Type: alert.TypePushover,
|
||||
Enabled: &enabled,
|
||||
FailureThreshold: 1,
|
||||
SuccessThreshold: 1,
|
||||
SendOnResolved: &enabled,
|
||||
Triggered: false,
|
||||
},
|
||||
},
|
||||
NumberOfFailuresInARow: 0,
|
||||
}
|
||||
|
||||
HandleAlerting(endpoint, &core.Result{Success: false}, cfg.Alerting, cfg.Debug)
|
||||
verify(t, endpoint, 1, 0, true, "")
|
||||
|
||||
HandleAlerting(endpoint, &core.Result{Success: true}, cfg.Alerting, cfg.Debug)
|
||||
verify(t, endpoint, 0, 1, false, "The alert should've been resolved")
|
||||
}
|
||||
|
||||
func TestHandleAlertingWithProviderThatReturnsAnError(t *testing.T) {
|
||||
_ = os.Setenv("MOCK_ALERT_PROVIDER", "true")
|
||||
defer os.Clearenv()
|
||||
@ -273,6 +310,16 @@ func TestHandleAlertingWithProviderThatReturnsAnError(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "pushover",
|
||||
AlertType: alert.TypePushover,
|
||||
AlertingConfig: &alerting.Config{
|
||||
Pushover: &pushover.AlertProvider{
|
||||
ApplicationToken: "000000000000000000000000000000",
|
||||
UserKey: "000000000000000000000000000000",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "slack",
|
||||
AlertType: alert.TypeSlack,
|
||||
|
Reference in New Issue
Block a user