2020-03-04 10:29:00 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2020-03-09 18:17:55 +00:00
|
|
|
"github.com/statping/statping/notifiers"
|
2020-03-08 18:13:27 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-03-04 10:29:00 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2020-03-08 21:32:26 +00:00
|
|
|
func TestAttachment(t *testing.T) {
|
2020-03-15 21:36:55 +00:00
|
|
|
notifiers.InitNotifiers()
|
2020-03-08 21:32:26 +00:00
|
|
|
}
|
|
|
|
|
2020-03-04 10:29:00 +00:00
|
|
|
func TestApiNotifiersRoutes(t *testing.T) {
|
|
|
|
tests := []HTTPTest{
|
|
|
|
{
|
|
|
|
Name: "Statping Notifiers",
|
|
|
|
URL: "/api/notifiers",
|
|
|
|
Method: "GET",
|
|
|
|
ExpectedStatus: 200,
|
2020-03-08 18:13:27 +00:00
|
|
|
BeforeTest: SetTestENV,
|
2020-03-04 10:29:00 +00:00
|
|
|
}, {
|
|
|
|
Name: "Statping Mobile Notifier",
|
|
|
|
URL: "/api/notifier/mobile",
|
|
|
|
Method: "GET",
|
|
|
|
ExpectedStatus: 200,
|
2020-03-08 18:13:27 +00:00
|
|
|
BeforeTest: SetTestENV,
|
2020-03-04 10:29:00 +00:00
|
|
|
}, {
|
|
|
|
Name: "Statping Update Notifier",
|
|
|
|
URL: "/api/notifier/mobile",
|
|
|
|
Method: "POST",
|
|
|
|
Body: `{
|
2020-03-08 18:13:27 +00:00
|
|
|
"method": "mobile",
|
|
|
|
"var1": "ExponentPushToken[ToBadIWillError123456]",
|
|
|
|
"enabled": true,
|
|
|
|
"limits": 55
|
|
|
|
}`,
|
2020-03-04 10:29:00 +00:00
|
|
|
ExpectedStatus: 200,
|
2020-03-08 18:13:27 +00:00
|
|
|
BeforeTest: SetTestENV,
|
2020-03-04 10:29:00 +00:00
|
|
|
}}
|
|
|
|
|
|
|
|
for _, v := range tests {
|
|
|
|
t.Run(v.Name, func(t *testing.T) {
|
|
|
|
_, t, err := RunHTTPTest(v, t)
|
2020-03-08 18:13:27 +00:00
|
|
|
assert.Nil(t, err)
|
2020-03-04 10:29:00 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|