update code format.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
a6f0de8029
commit
9c7aef4533
|
@ -139,7 +139,14 @@ func LogRequest(uri string, method string, ip string, contentType string, agent
|
|||
output = string(logJson)
|
||||
} else {
|
||||
// format is string
|
||||
output = fmt.Sprintf("|%s header %s| %s %s %s %s %s", magenta, reset, log.Method, log.URI, log.IP, log.ContentType, log.Agent)
|
||||
output = fmt.Sprintf("|%s header %s| %s %s %s %s %s",
|
||||
magenta, reset,
|
||||
log.Method,
|
||||
log.URI,
|
||||
log.IP,
|
||||
log.ContentType,
|
||||
log.Agent,
|
||||
)
|
||||
}
|
||||
|
||||
LogAccess.Info(output)
|
||||
|
@ -193,9 +200,20 @@ func LogPush(status, token string, req RequestPushNotification, errPush error) {
|
|||
} else {
|
||||
switch status {
|
||||
case StatusSucceededPush:
|
||||
output = fmt.Sprintf("|%s %s %s| %s%s%s [%s] %s", green, log.Type, reset, platColor, log.Platform, reset, log.Token, log.Message)
|
||||
output = fmt.Sprintf("|%s %s %s| %s%s%s [%s] %s",
|
||||
green, log.Type, reset,
|
||||
platColor, log.Platform, reset,
|
||||
log.Token,
|
||||
log.Message,
|
||||
)
|
||||
case StatusFailedPush:
|
||||
output = fmt.Sprintf("|%s %s %s| %s%s%s [%s] | %s | Error Message: %s", red, log.Type, reset, platColor, log.Platform, reset, log.Token, log.Message, log.Error)
|
||||
output = fmt.Sprintf("|%s %s %s| %s%s%s [%s] | %s | Error Message: %s",
|
||||
red, log.Type, reset,
|
||||
platColor, log.Platform, reset,
|
||||
log.Token,
|
||||
log.Message,
|
||||
log.Error,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ func TestDisabledAndroidPushHandler(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAndroidPushHandler(t *testing.T) {
|
||||
func TestHalfSuccessAndroidPushHandler(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
PushConf.Android.Enabled = true
|
||||
|
@ -223,3 +223,30 @@ func TestAndroidPushHandler(t *testing.T) {
|
|||
assert.Equal(t, http.StatusOK, r.Code)
|
||||
})
|
||||
}
|
||||
|
||||
func TestAllSuccessAndroidPushHandler(t *testing.T) {
|
||||
initTest()
|
||||
|
||||
PushConf.Android.Enabled = true
|
||||
PushConf.Android.ApiKey = os.Getenv("ANDROID_API_KEY")
|
||||
// log for json
|
||||
PushConf.Log.Format = "json"
|
||||
|
||||
android_token := os.Getenv("ANDROID_TEST_TOKEN")
|
||||
|
||||
r := gofight.New()
|
||||
|
||||
r.POST("/api/push").
|
||||
SetJSON(gofight.D{
|
||||
"tokens": []string{android_token, android_token},
|
||||
"platform": 2,
|
||||
"message": "Welcome",
|
||||
}).
|
||||
Run(GetMainEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
|
||||
|
||||
assert.Equal(t, http.StatusOK, r.Code)
|
||||
})
|
||||
|
||||
// wait push response
|
||||
time.Sleep(3000 * time.Millisecond)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue