Improve test coverage
This commit is contained in:
parent
4be2273662
commit
4d186c6e71
@ -96,9 +96,6 @@ func TestService_GetAlertsTriggered(t *testing.T) {
|
|||||||
URL: "https://twinnation.org/health",
|
URL: "https://twinnation.org/health",
|
||||||
Conditions: []*Condition{&condition},
|
Conditions: []*Condition{&condition},
|
||||||
Alerts: []*Alert{{Type: PagerDutyAlert, Enabled: true}},
|
Alerts: []*Alert{{Type: PagerDutyAlert, Enabled: true}},
|
||||||
Headers: map[string]string{
|
|
||||||
"Host": "twinnation.org",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
service.ValidateAndSetDefaults()
|
service.ValidateAndSetDefaults()
|
||||||
if service.NumberOfFailuresInARow != 0 {
|
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) {
|
func TestIntegrationEvaluateHealth(t *testing.T) {
|
||||||
condition := Condition("[STATUS] == 200")
|
condition := Condition("[STATUS] == 200")
|
||||||
service := Service{
|
service := Service{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user