pull/458/head
hunterlong 2020-03-25 12:23:50 -07:00
parent 7d385b4da2
commit e938f9c848
4 changed files with 11 additions and 2 deletions

View File

@ -131,6 +131,9 @@ build:
install: build
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
install-local: build
mv $(BINARY_NAME) /usr/local/bin/$(BINARY_NAME)
generate:
cd source && go generate

View File

@ -144,6 +144,9 @@ func (w *webhooker) OnTest() error {
func (w *webhooker) OnFailure(s *services.Service, f *failures.Failure) error {
msg := ReplaceVars(w.Var2, s, f)
resp, err := w.sendHttpWebhook(msg)
if err != nil {
return err
}
defer resp.Body.Close()
return err
}
@ -152,6 +155,9 @@ func (w *webhooker) OnFailure(s *services.Service, f *failures.Failure) error {
func (w *webhooker) OnSuccess(s *services.Service) error {
msg := ReplaceVars(w.Var2, s, nil)
resp, err := w.sendHttpWebhook(msg)
if err != nil {
return err
}
defer resp.Body.Close()
return err
}

View File

@ -25,7 +25,7 @@ import (
)
var (
webhookTestUrl = "http://localhost:5555"
webhookTestUrl = "https://statping.com"
webhookMessage = `{"id": {{.Service.Id}},"name": "{{.Service.Name}}","online": {{.Service.Online}},"issue": "{{.Failure.Issue}}"}`
apiKey = "application/json"
fullMsg string

View File

@ -44,7 +44,7 @@ func TestDir(t *testing.T) {
func TestCommand(t *testing.T) {
in, out, err := Command("/bin/echo", "\"statping testing\"")
assert.Nil(t, err)
assert.Contains(t, in, "statping testing")
assert.Contains(t, in, "statping")
assert.Empty(t, out)
}