Remove unused code
This commit is contained in:
		| @ -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") | ||||
|  | ||||
| @ -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{ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user