fix(debug): show error message. (#356)

This commit is contained in:
Bo-Yi Wu 2018-05-22 10:19:13 +08:00 committed by GitHub
parent 1b2a418ad3
commit a8994a5110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -49,7 +49,7 @@ func pushHandler(c *gin.Context) {
if err := c.ShouldBindWith(&form, binding.JSON); err != nil {
msg = "Missing notifications field."
LogAccess.Debug(msg)
LogAccess.Debug(err)
abortWithError(c, http.StatusBadRequest, msg)
return
}

View File

@ -218,6 +218,35 @@ func TestEmptyNotifications(t *testing.T) {
})
}
func TestMutableContent(t *testing.T) {
initTest()
r := gofight.New()
// notifications is empty.
r.POST("/api/push").
SetJSON(gofight.D{
"notifications": []gofight.D{
{
"tokens": []string{"aaaaa", "bbbbb"},
"platform": PlatFormAndroid,
"message": "Welcome",
"mutable-content": 1,
"topic": "test",
"badge": 1,
"alert": gofight.D{
"title": "title",
"body": "body",
},
},
},
}).
Run(routerEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
// json: cannot unmarshal number into Go struct field PushNotification.mutable-content of type bool
assert.Equal(t, http.StatusBadRequest, r.Code)
})
}
func TestOutOfRangeMaxNotifications(t *testing.T) {
initTest()