fix: check return value (#256)

* fix: check return value

* fix testing

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2017-07-24 21:41:21 +08:00 committed by GitHub
parent a64fae7de7
commit 2e3cc8e281
2 changed files with 16 additions and 13 deletions

View File

@ -126,5 +126,5 @@ Retry:
goto Retry goto Retry
} }
return !isError return isError
} }

View File

@ -442,6 +442,7 @@ func TestPushToIOS(t *testing.T) {
Message: "Welcome", Message: "Welcome",
} }
// send fail
isError := PushToIOS(req) isError := PushToIOS(req)
assert.True(t, isError) assert.True(t, isError)
} }
@ -458,8 +459,9 @@ func TestPushToAndroidWrongAPIKey(t *testing.T) {
Message: "Welcome", Message: "Welcome",
} }
success := PushToAndroid(req) // FCM server error: 401 error: 401 Unauthorized
assert.False(t, success) err := PushToAndroid(req)
assert.False(t, err)
} }
func TestPushToAndroidWrongToken(t *testing.T) { func TestPushToAndroidWrongToken(t *testing.T) {
@ -474,8 +476,8 @@ func TestPushToAndroidWrongToken(t *testing.T) {
Message: "Welcome", Message: "Welcome",
} }
success := PushToAndroid(req) isError := PushToAndroid(req)
assert.False(t, success) assert.True(t, isError)
} }
func TestPushToAndroidRightTokenForJSONLog(t *testing.T) { func TestPushToAndroidRightTokenForJSONLog(t *testing.T) {
@ -494,8 +496,8 @@ func TestPushToAndroidRightTokenForJSONLog(t *testing.T) {
Message: "Welcome", Message: "Welcome",
} }
success := PushToAndroid(req) isError := PushToAndroid(req)
assert.True(t, success) assert.False(t, isError)
} }
func TestPushToAndroidRightTokenForStringLog(t *testing.T) { func TestPushToAndroidRightTokenForStringLog(t *testing.T) {
@ -512,8 +514,8 @@ func TestPushToAndroidRightTokenForStringLog(t *testing.T) {
Message: "Welcome", Message: "Welcome",
} }
success := PushToAndroid(req) isError := PushToAndroid(req)
assert.False(t, success) assert.True(t, isError)
} }
func TestOverwriteAndroidAPIKey(t *testing.T) { func TestOverwriteAndroidAPIKey(t *testing.T) {
@ -532,8 +534,9 @@ func TestOverwriteAndroidAPIKey(t *testing.T) {
APIKey: "1234", APIKey: "1234",
} }
success := PushToAndroid(req) // FCM server error: 401 error: 401 Unauthorized
assert.False(t, success) err := PushToAndroid(req)
assert.False(t, err)
} }
func TestSenMultipleNotifications(t *testing.T) { func TestSenMultipleNotifications(t *testing.T) {
@ -781,8 +784,8 @@ func TestCheckAndroidMessage(t *testing.T) {
TimeToLive: &timeToLive, TimeToLive: &timeToLive,
} }
success := PushToAndroid(req) err := PushToAndroid(req)
assert.False(t, success) assert.False(t, err)
} }
func TestSetProxyURL(t *testing.T) { func TestSetProxyURL(t *testing.T) {