Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification API should always return a JSON object with the current count of notifications #10059

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update Tests
  • Loading branch information
6543 committed Apr 9, 2020
commit a4075e3b169846a6740c7808d0d2c7877e83176f
10 changes: 9 additions & 1 deletion integrations/api_notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
}