Skip to content

Commit ccf5191

Browse files
Fix dismiss_notification to accept HTTP 204 No Content response
- Add http.StatusNoContent (204) to the list of accepted success status codes - Add test case for 204 response when marking notification as done - Retain existing test for 200 response for backwards compatibility Co-authored-by: SamMorrowDrums <[email protected]>
1 parent d88eb83 commit ccf5191

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pkg/github/notifications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func DismissNotification(t translations.TranslationHelperFunc) inventory.ServerT
231231
}
232232
defer func() { _ = resp.Body.Close() }()
233233

234-
if resp.StatusCode != http.StatusResetContent && resp.StatusCode != http.StatusOK {
234+
if resp.StatusCode != http.StatusResetContent && resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusOK {
235235
body, err := io.ReadAll(resp.Body)
236236
if err != nil {
237237
return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, nil

pkg/github/notifications_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,19 @@ func Test_DismissNotification(t *testing.T) {
472472
expectRead: true,
473473
},
474474
{
475-
name: "mark as done",
475+
name: "mark as done with 204 response",
476+
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
477+
DeleteNotificationsThreadsByThreadID: mockResponse(t, http.StatusNoContent, nil),
478+
}),
479+
requestArgs: map[string]interface{}{
480+
"threadID": "123",
481+
"state": "done",
482+
},
483+
expectError: false,
484+
expectDone: true,
485+
},
486+
{
487+
name: "mark as done with 200 response",
476488
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
477489
DeleteNotificationsThreadsByThreadID: mockResponse(t, http.StatusOK, nil),
478490
}),

0 commit comments

Comments
 (0)