From 533f52a39dfbd568c7f0020e76d40586192ae56b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 29 Jan 2020 14:05:46 +0100 Subject: [PATCH 1/3] BEAKING: check return status based on struct not httpStatus --- routers/api/v1/notify/notifications.go | 13 ++----------- templates/swagger/v1_json.tmpl | 3 --- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/routers/api/v1/notify/notifications.go b/routers/api/v1/notify/notifications.go index 847fe3313e0d5..71dd7d949267f 100644 --- a/routers/api/v1/notify/notifications.go +++ b/routers/api/v1/notify/notifications.go @@ -19,15 +19,6 @@ func NewAvailable(ctx *context.APIContext) { // summary: Check if unread notifications exist // responses: // "200": - // "$ref": "#/responses/NotificationCount" - // "204": - // description: No unread notification - - count := models.CountUnread(ctx.User) - - if count > 0 { - ctx.JSON(http.StatusOK, api.NotificationCount{New: count}) - } else { - ctx.Status(http.StatusNoContent) - } + // "$ref": "#/responses/NotificationCount" + ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx.User)}) } diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 55094e391dabc..c27a23ade5492 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -530,9 +530,6 @@ "responses": { "200": { "$ref": "#/responses/NotificationCount" - }, - "204": { - "description": "No unread notification" } } } From a4075e3b169846a6740c7808d0d2c7877e83176f Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 9 Apr 2020 17:23:09 +0200 Subject: [PATCH 2/3] update Tests --- integrations/api_notification_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/integrations/api_notification_test.go b/integrations/api_notification_test.go index baab00f6d29bb..3296604a081fc 100644 --- a/integrations/api_notification_test.go +++ b/integrations/api_notification_test.go @@ -81,9 +81,15 @@ func TestAPINotification(t *testing.T) { assert.EqualValues(t, thread5.Issue.APIURL(), apiN.Subject.URL) assert.EqualValues(t, thread5.Repository.HTMLURL(), apiN.Repository.HTMLURL) + new := struct { + New int64 `json:"new"` + }{} + // -- check notifications -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/new?token=%s", token)) resp = session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &new) + assert.True(t, new.New > 0) // -- mark notifications as read -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?token=%s", token)) @@ -110,5 +116,7 @@ func TestAPINotification(t *testing.T) { // -- check notifications -- req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/new?token=%s", token)) - resp = session.MakeRequest(t, req, http.StatusNoContent) + resp = session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &new) + assert.True(t, new.New == 0) } From 191c285d0303004c7833f0e2c66b27ca89b4ce03 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 9 Apr 2020 18:53:14 +0200 Subject: [PATCH 3/3] CI.restart()