mirror of https://github.com/statping/statping
tests
parent
7d385b4da2
commit
e938f9c848
3
Makefile
3
Makefile
|
@ -131,6 +131,9 @@ build:
|
||||||
install: build
|
install: build
|
||||||
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
|
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
|
||||||
|
|
||||||
|
install-local: build
|
||||||
|
mv $(BINARY_NAME) /usr/local/bin/$(BINARY_NAME)
|
||||||
|
|
||||||
generate:
|
generate:
|
||||||
cd source && go generate
|
cd source && go generate
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,9 @@ func (w *webhooker) OnTest() error {
|
||||||
func (w *webhooker) OnFailure(s *services.Service, f *failures.Failure) error {
|
func (w *webhooker) OnFailure(s *services.Service, f *failures.Failure) error {
|
||||||
msg := ReplaceVars(w.Var2, s, f)
|
msg := ReplaceVars(w.Var2, s, f)
|
||||||
resp, err := w.sendHttpWebhook(msg)
|
resp, err := w.sendHttpWebhook(msg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
return err
|
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 {
|
func (w *webhooker) OnSuccess(s *services.Service) error {
|
||||||
msg := ReplaceVars(w.Var2, s, nil)
|
msg := ReplaceVars(w.Var2, s, nil)
|
||||||
resp, err := w.sendHttpWebhook(msg)
|
resp, err := w.sendHttpWebhook(msg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
webhookTestUrl = "http://localhost:5555"
|
webhookTestUrl = "https://statping.com"
|
||||||
webhookMessage = `{"id": {{.Service.Id}},"name": "{{.Service.Name}}","online": {{.Service.Online}},"issue": "{{.Failure.Issue}}"}`
|
webhookMessage = `{"id": {{.Service.Id}},"name": "{{.Service.Name}}","online": {{.Service.Online}},"issue": "{{.Failure.Issue}}"}`
|
||||||
apiKey = "application/json"
|
apiKey = "application/json"
|
||||||
fullMsg string
|
fullMsg string
|
||||||
|
|
|
@ -44,7 +44,7 @@ func TestDir(t *testing.T) {
|
||||||
func TestCommand(t *testing.T) {
|
func TestCommand(t *testing.T) {
|
||||||
in, out, err := Command("/bin/echo", "\"statping testing\"")
|
in, out, err := Command("/bin/echo", "\"statping testing\"")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Contains(t, in, "statping testing")
|
assert.Contains(t, in, "statping")
|
||||||
assert.Empty(t, out)
|
assert.Empty(t, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue