fix testing.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-04-14 23:58:25 +08:00
parent 2523b03d7a
commit b877f1cc9e
2 changed files with 8 additions and 5 deletions

View File

@ -260,7 +260,9 @@ func GetIOSNotification(req PushNotification) *apns.Notification {
}
// PushToIOS provide send notification to APNs server.
func PushToIOS(req PushNotification) {
func PushToIOS(req PushNotification) bool {
var isError bool
notification := GetIOSNotification(req)
@ -273,7 +275,7 @@ func PushToIOS(req PushNotification) {
if err != nil {
// apns server error
LogPush(FailedPush, token, req, err)
isError = true
continue
}
@ -281,7 +283,6 @@ func PushToIOS(req PushNotification) {
// error message:
// ref: https://github.com/sideshow/apns2/blob/master/response.go#L14-L65
LogPush(FailedPush, token, req, errors.New(res.Reason))
continue
}
@ -289,6 +290,8 @@ func PushToIOS(req PushNotification) {
LogPush(SucceededPush, token, req, nil)
}
}
return isError
}
// GetAndroidNotification use for define Android notificaiton.

View File

@ -229,8 +229,8 @@ func TestPushToIOS(t *testing.T) {
Message: "Welcome",
}
PushToIOS(req)
// assert.False(t, success)
isError := PushToIOS(req)
assert.True(t, isError)
}
func TestPushToAndroidWrongAPIKey(t *testing.T) {