diff --git a/core/service_test.go b/core/service_test.go index 893a2788..6d2596d2 100644 --- a/core/service_test.go +++ b/core/service_test.go @@ -96,9 +96,6 @@ func TestService_GetAlertsTriggered(t *testing.T) { URL: "https://twinnation.org/health", Conditions: []*Condition{&condition}, Alerts: []*Alert{{Type: PagerDutyAlert, Enabled: true}}, - Headers: map[string]string{ - "Host": "twinnation.org", - }, } service.ValidateAndSetDefaults() if service.NumberOfFailuresInARow != 0 { @@ -116,6 +113,37 @@ func TestService_GetAlertsTriggered(t *testing.T) { } } +func TestService_buildHTTPRequest(t *testing.T) { + condition := Condition("[STATUS] == 200") + service := Service{ + Name: "TwiNNatioN", + URL: "https://twinnation.org/health", + Conditions: []*Condition{&condition}, + } + service.ValidateAndSetDefaults() + request := service.buildHTTPRequest() + if request.Host != "twinnation.org" { + t.Error("request's Host should've been twinnation.org, but was", request.Host) + } +} + +func TestService_buildHTTPRequestWithHostHeader(t *testing.T) { + condition := Condition("[STATUS] == 200") + service := Service{ + Name: "TwiNNatioN", + URL: "https://twinnation.org/health", + Conditions: []*Condition{&condition}, + Headers: map[string]string{ + "Host": "example.com", + }, + } + service.ValidateAndSetDefaults() + request := service.buildHTTPRequest() + if request.Host != "example.com" { + t.Error("request's Host should've been example.org, but was", request.Host) + } +} + func TestIntegrationEvaluateHealth(t *testing.T) { condition := Condition("[STATUS] == 200") service := Service{