mirror of https://github.com/statping/statping
parent
0ef00d682c
commit
60100461c9
|
@ -1,7 +1,6 @@
|
|||
package notifiers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/statping/statping/database"
|
||||
"github.com/statping/statping/types/notifications"
|
||||
"github.com/statping/statping/types/null"
|
||||
|
@ -55,17 +54,6 @@ func TestEmailNotifier(t *testing.T) {
|
|||
Add(email)
|
||||
assert.Equal(t, "Hunter Long", email.Author)
|
||||
assert.Equal(t, EMAIL_HOST, email.Host)
|
||||
|
||||
testEmail = &emailOutgoing{
|
||||
To: email.GetValue("var2"),
|
||||
Subject: fmt.Sprintf("Service %v is Failing", exampleService.Name),
|
||||
Template: mainEmailTemplate,
|
||||
Data: replacer{
|
||||
Service: exampleService,
|
||||
Failure: exampleFailure,
|
||||
},
|
||||
From: email.GetValue("var1"),
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("email Within Limits", func(t *testing.T) {
|
||||
|
|
|
@ -62,7 +62,7 @@ var Twilio = &twilio{¬ifications.Notification{
|
|||
|
||||
// Send will send a HTTP Post to the Twilio SMS API. It accepts type: string
|
||||
func (t *twilio) sendMessage(message string) (string, error) {
|
||||
twilioUrl := fmt.Sprintf("https://api.twilio.com/2010-04-01/Accounts/%v/Messages.json", t.ApiKey)
|
||||
twilioUrl := fmt.Sprintf("https://api.twilio.com/2010-04-01/Accounts/%s/Messages.json", t.ApiKey)
|
||||
|
||||
v := url.Values{}
|
||||
v.Set("To", "+"+t.Var1)
|
||||
|
@ -76,7 +76,10 @@ func (t *twilio) sendMessage(message string) (string, error) {
|
|||
success, _ := twilioSuccess(contents)
|
||||
if !success {
|
||||
errorOut := twilioError(contents)
|
||||
out := fmt.Sprintf("Error code %v - %v", errorOut.Code, errorOut.Message)
|
||||
if errorOut.Code == 0 {
|
||||
return string(contents), nil
|
||||
}
|
||||
out := fmt.Sprintf("Error code %v - %s", errorOut.Code, errorOut.Message)
|
||||
return string(contents), errors.New(out)
|
||||
}
|
||||
return string(contents), err
|
||||
|
|
Loading…
Reference in New Issue