Avoid panic when push messages are empty or nil (#13751)

Этот коммит содержится в:
Mario de Frutos Dieguez
2020-01-29 10:08:27 +01:00
коммит произвёл GitHub
родитель 3049378506
Коммит 682a1d5d15
7 изменённых файлов: 137 добавлений и 13 удалений

Просмотреть файл

@@ -627,3 +627,20 @@ func TestServerBusy503(t *testing.T) {
CheckNoError(t, resp)
})
}
func TestPushNotificationAck(t *testing.T) {
th := Setup().InitBasic()
api := Init(th.Server, th.Server.AppOptions, th.Server.Router)
session, _ := th.App.GetSession(th.Client.AuthToken)
defer th.TearDown()
t.Run("should return error when the ack body is not passed", func(t *testing.T) {
handler := api.ApiHandler(pushNotificationAck)
resp := httptest.NewRecorder()
req := httptest.NewRequest("POST", "/api/v4/notifications/ack", nil)
req.Header.Set(model.HEADER_AUTH, "Bearer "+session.Token)
handler.ServeHTTP(resp, req)
assert.Equal(t, http.StatusBadRequest, resp.Code)
assert.NotNil(t, resp.Body)
})
}