fix lint error for gorush folder. (#275)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2017-08-23 21:46:00 -05:00 committed by GitHub
parent acc83c1fa5
commit e070248a11
7 changed files with 33 additions and 20 deletions

View File

@ -30,7 +30,10 @@ func TestWrongYAMLormat(t *testing.T) {
}
// clean up
defer os.Remove(filename)
defer func() {
err := os.Remove(filename)
assert.Nil(t, err)
}()
// parse JSON format error
_, err := LoadConfYaml(filename)

View File

@ -67,11 +67,11 @@ func InitLog() error {
}
// set logger
if err := SetLogLevel(LogAccess, PushConf.Log.AccessLevel); err != nil {
if err = SetLogLevel(LogAccess, PushConf.Log.AccessLevel); err != nil {
return errors.New("Set access log level error: " + err.Error())
}
if err := SetLogLevel(LogError, PushConf.Log.ErrorLevel); err != nil {
if err = SetLogLevel(LogError, PushConf.Log.ErrorLevel); err != nil {
return errors.New("Set error log level error: " + err.Error())
}
@ -206,7 +206,7 @@ func getLogPushEntry(status, token string, req PushNotification, errPush error)
errMsg = errPush.Error()
}
if PushConf.Log.HideToken == true {
if PushConf.Log.HideToken {
token = hideToken(token, 10)
}

View File

@ -215,7 +215,7 @@ Retry:
}
}
if isError == true && retryCount < maxRetry {
if isError && retryCount < maxRetry {
retryCount++
// resend fail token

View File

@ -349,7 +349,8 @@ func TestDisabledIosNotifications(t *testing.T) {
PushConf.Ios.Enabled = false
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
InitAPNSClient()
err := InitAPNSClient()
assert.Nil(t, err)
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")
@ -394,8 +395,8 @@ func TestAPNSClientDevHost(t *testing.T) {
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.p12"
InitAPNSClient()
err := InitAPNSClient()
assert.Nil(t, err)
assert.Equal(t, apns2.HostDevelopment, ApnsClient.Host)
}
@ -405,8 +406,8 @@ func TestAPNSClientProdHost(t *testing.T) {
PushConf.Ios.Enabled = true
PushConf.Ios.Production = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
InitAPNSClient()
err := InitAPNSClient()
assert.Nil(t, err)
assert.Equal(t, apns2.HostProduction, ApnsClient.Host)
}
@ -415,8 +416,10 @@ func TestPushToIOS(t *testing.T) {
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
InitAPNSClient()
InitAppStatus()
err := InitAPNSClient()
assert.Nil(t, err)
err = InitAppStatus()
assert.Nil(t, err)
req := PushNotification{
Tokens: []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"},

View File

@ -141,7 +141,7 @@ Retry:
LogPush(SucceededPush, req.Tokens[k], req, nil)
}
if isError == true && retryCount < maxRetry {
if isError && retryCount < maxRetry {
retryCount++
// resend fail token

View File

@ -29,7 +29,8 @@ func TestSenMultipleNotifications(t *testing.T) {
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
InitAPNSClient()
err := InitAPNSClient()
assert.Nil(t, err)
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")
@ -63,7 +64,8 @@ func TestDisabledAndroidNotifications(t *testing.T) {
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
InitAPNSClient()
err := InitAPNSClient()
assert.Nil(t, err)
PushConf.Android.Enabled = false
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")
@ -97,7 +99,8 @@ func TestSyncModeForNotifications(t *testing.T) {
PushConf.Ios.Enabled = true
PushConf.Ios.KeyPath = "../certificate/certificate-valid.pem"
InitAPNSClient()
err := InitAPNSClient()
assert.Nil(t, err)
PushConf.Android.Enabled = true
PushConf.Android.APIKey = os.Getenv("ANDROID_API_KEY")

View File

@ -19,7 +19,8 @@ func TestStatForMemoryEngine(t *testing.T) {
var val int64
PushConf.Stat.Engine = "memory"
InitAppStatus()
err := InitAppStatus()
assert.Nil(t, err)
StatStorage.AddTotalCount(100)
StatStorage.AddIosSuccess(200)
@ -61,7 +62,8 @@ func TestStatForRedisEngine(t *testing.T) {
var val int64
PushConf.Stat.Engine = "redis"
PushConf.Stat.Redis.Addr = "redis:6379"
InitAppStatus()
err := InitAppStatus()
assert.Nil(t, err)
StatStorage.Init()
StatStorage.Reset()
@ -87,7 +89,8 @@ func TestStatForRedisEngine(t *testing.T) {
func TestDefaultEngine(t *testing.T) {
var val int64
// defaul engine as memory
InitAppStatus()
err := InitAppStatus()
assert.Nil(t, err)
StatStorage.Reset()
@ -137,7 +140,8 @@ func TestStatForBoltDBEngine(t *testing.T) {
func TestStatForBuntDBEngine(t *testing.T) {
var val int64
PushConf.Stat.Engine = "buntdb"
InitAppStatus()
err := InitAppStatus()
assert.Nil(t, err)
StatStorage.Reset()