diff --git a/core/service.go b/core/service.go index 2e3f8dbc..b974ee14 100644 --- a/core/service.go +++ b/core/service.go @@ -155,21 +155,6 @@ func (service *Service) EvaluateHealth() *Result { return result } -// GetAlertsTriggered returns a slice of alerts that have been triggered -func (service *Service) GetAlertsTriggered() []alert.Alert { - var alerts []alert.Alert - if service.NumberOfFailuresInARow == 0 { - return alerts - } - for _, alert := range service.Alerts { - if alert.IsEnabled() && alert.FailureThreshold == service.NumberOfFailuresInARow { - alerts = append(alerts, *alert) - continue - } - } - return alerts -} - func (service *Service) getIP(result *Result) { if service.DNS != nil { result.Hostname = strings.TrimSuffix(service.URL, ":53") diff --git a/core/service_test.go b/core/service_test.go index 0d3449f4..712c6bae 100644 --- a/core/service_test.go +++ b/core/service_test.go @@ -102,31 +102,6 @@ func TestService_ValidateAndSetDefaultsWithDNS(t *testing.T) { } } -func TestService_GetAlertsTriggered(t *testing.T) { - condition := Condition("[STATUS] == 200") - enabled := true - service := Service{ - Name: "twinnation-health", - URL: "https://twinnation.org/health", - Conditions: []*Condition{&condition}, - Alerts: []*alert.Alert{{Type: alert.TypePagerDuty, Enabled: &enabled}}, - } - service.ValidateAndSetDefaults() - if service.NumberOfFailuresInARow != 0 { - t.Error("Service.NumberOfFailuresInARow should start with 0") - } - if service.NumberOfSuccessesInARow != 0 { - t.Error("Service.NumberOfSuccessesInARow should start with 0") - } - if len(service.GetAlertsTriggered()) > 0 { - t.Error("No alerts should've been triggered, because service.NumberOfFailuresInARow is 0, which is below the failure threshold") - } - service.NumberOfFailuresInARow = service.Alerts[0].FailureThreshold - if len(service.GetAlertsTriggered()) != 1 { - t.Error("Alert should've been triggered") - } -} - func TestService_buildHTTPRequest(t *testing.T) { condition := Condition("[STATUS] == 200") service := Service{