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

View File

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