add ios and android test.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
64db4504bb
commit
3538cfba4d
|
@ -197,6 +197,7 @@ func pushNotificationIos(req RequestPushNotification) bool {
|
|||
|
||||
if res.Sent() {
|
||||
log.Println("APNs ID:", res.ApnsID)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestAPIStatusHandler(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestPushHandler(t *testing.T) {
|
||||
func TestMissingParameterPushHandler(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
r := gofight.New()
|
||||
|
@ -63,3 +63,42 @@ func TestPushHandler(t *testing.T) {
|
|||
assert.Equal(t, http.StatusBadRequest, r.Code)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIosPushHandler(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
PushConf.Ios.Enabled = false
|
||||
InitAPNSClient()
|
||||
|
||||
r := gofight.New()
|
||||
|
||||
r.POST("/api/push").
|
||||
SetJSON(gofight.D{
|
||||
"tokens": []string{"dc0ca2819417e528d8a4a01fc3e6bc7d2518ce738930c3b11203c0ef7c0fab8c"},
|
||||
"platform": 1,
|
||||
"message": "Welcome",
|
||||
}).
|
||||
Run(GetMainEngine(), func(r gofight.HttpResponse, rq gofight.HttpRequest) {
|
||||
|
||||
assert.Equal(t, http.StatusOK, r.Code)
|
||||
})
|
||||
}
|
||||
|
||||
func TestAndroidPushHandler(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
PushConf.Android.Enabled = true
|
||||
|
||||
r := gofight.New()
|
||||
|
||||
r.POST("/api/push").
|
||||
SetJSON(gofight.D{
|
||||
"tokens": []string{"aaaaaa", "bbbbb"},
|
||||
"platform": 2,
|
||||
"message": "Welcome",
|
||||
}).
|
||||
Run(GetMainEngine(), func(r gofight.HttpResponse, rq gofight.HttpRequest) {
|
||||
|
||||
assert.Equal(t, http.StatusOK, r.Code)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue