Remove unused code

This commit is contained in:
TwinProduction 2021-05-28 18:48:17 -04:00
parent 1f6f0ce426
commit 8e02572880
2 changed files with 0 additions and 40 deletions

View File

@ -155,21 +155,6 @@ func (service *Service) EvaluateHealth() *Result {
return 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) { func (service *Service) getIP(result *Result) {
if service.DNS != nil { if service.DNS != nil {
result.Hostname = strings.TrimSuffix(service.URL, ":53") result.Hostname = strings.TrimSuffix(service.URL, ":53")

View File

@ -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) { func TestService_buildHTTPRequest(t *testing.T) {
condition := Condition("[STATUS] == 200") condition := Condition("[STATUS] == 200")
service := Service{ service := Service{