fix(debug): show error message. (#356)
This commit is contained in:
parent
1b2a418ad3
commit
a8994a5110
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue