Rename buildRequest to buildHTTPRequest
This commit is contained in:
parent
46d476128d
commit
7f9fe9acdf
@ -31,7 +31,7 @@ func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, aler
|
|||||||
return provider
|
return provider
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *AlertProvider) buildRequest(serviceName, alertDescription string, resolved bool) *http.Request {
|
func (provider *AlertProvider) buildHTTPRequest(serviceName, alertDescription string, resolved bool) *http.Request {
|
||||||
body := provider.Body
|
body := provider.Body
|
||||||
providerURL := provider.URL
|
providerURL := provider.URL
|
||||||
method := provider.Method
|
method := provider.Method
|
||||||
@ -74,7 +74,7 @@ func (provider *AlertProvider) buildRequest(serviceName, alertDescription string
|
|||||||
|
|
||||||
// Send a request to the alert provider and return the body
|
// Send a request to the alert provider and return the body
|
||||||
func (provider *AlertProvider) Send(serviceName, alertDescription string, resolved bool) ([]byte, error) {
|
func (provider *AlertProvider) Send(serviceName, alertDescription string, resolved bool) ([]byte, error) {
|
||||||
request := provider.buildRequest(serviceName, alertDescription, resolved)
|
request := provider.buildHTTPRequest(serviceName, alertDescription, resolved)
|
||||||
response, err := client.GetHTTPClient(provider.Insecure).Do(request)
|
response, err := client.GetHTTPClient(provider.Insecure).Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -17,7 +17,7 @@ func TestAlertProvider_IsValid(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAlertProvider_buildRequestWhenResolved(t *testing.T) {
|
func TestAlertProvider_buildHTTPRequestWhenResolved(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
ExpectedURL = "http://example.com/service-name?event=RESOLVED&description=alert-description"
|
ExpectedURL = "http://example.com/service-name?event=RESOLVED&description=alert-description"
|
||||||
ExpectedBody = "service-name,alert-description,RESOLVED"
|
ExpectedBody = "service-name,alert-description,RESOLVED"
|
||||||
@ -27,7 +27,7 @@ func TestAlertProvider_buildRequestWhenResolved(t *testing.T) {
|
|||||||
Body: "[SERVICE_NAME],[ALERT_DESCRIPTION],[ALERT_TRIGGERED_OR_RESOLVED]",
|
Body: "[SERVICE_NAME],[ALERT_DESCRIPTION],[ALERT_TRIGGERED_OR_RESOLVED]",
|
||||||
Headers: nil,
|
Headers: nil,
|
||||||
}
|
}
|
||||||
request := customAlertProvider.buildRequest("service-name", "alert-description", true)
|
request := customAlertProvider.buildHTTPRequest("service-name", "alert-description", true)
|
||||||
if request.URL.String() != ExpectedURL {
|
if request.URL.String() != ExpectedURL {
|
||||||
t.Error("expected URL to be", ExpectedURL, "was", request.URL.String())
|
t.Error("expected URL to be", ExpectedURL, "was", request.URL.String())
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ func TestAlertProvider_buildRequestWhenResolved(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAlertProvider_buildRequestWhenTriggered(t *testing.T) {
|
func TestAlertProvider_buildHTTPRequestWhenTriggered(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
ExpectedURL = "http://example.com/service-name?event=TRIGGERED&description=alert-description"
|
ExpectedURL = "http://example.com/service-name?event=TRIGGERED&description=alert-description"
|
||||||
ExpectedBody = "service-name,alert-description,TRIGGERED"
|
ExpectedBody = "service-name,alert-description,TRIGGERED"
|
||||||
@ -47,7 +47,7 @@ func TestAlertProvider_buildRequestWhenTriggered(t *testing.T) {
|
|||||||
Body: "[SERVICE_NAME],[ALERT_DESCRIPTION],[ALERT_TRIGGERED_OR_RESOLVED]",
|
Body: "[SERVICE_NAME],[ALERT_DESCRIPTION],[ALERT_TRIGGERED_OR_RESOLVED]",
|
||||||
Headers: map[string]string{"Authorization": "Basic hunter2"},
|
Headers: map[string]string{"Authorization": "Basic hunter2"},
|
||||||
}
|
}
|
||||||
request := customAlertProvider.buildRequest("service-name", "alert-description", false)
|
request := customAlertProvider.buildHTTPRequest("service-name", "alert-description", false)
|
||||||
if request.URL.String() != ExpectedURL {
|
if request.URL.String() != ExpectedURL {
|
||||||
t.Error("expected URL to be", ExpectedURL, "was", request.URL.String())
|
t.Error("expected URL to be", ExpectedURL, "was", request.URL.String())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user