From 65917f5bb98f1c0a0ce7285c284d25ea843c02c7 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:22:45 +0100 Subject: [bugfix] Log + ignore unknown notification types (#3577) * [bugfix] Log + ignore unknown notification types * pass context to ParseNotificationTypes --- .../client/notifications/notificationsget_test.go | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'internal/api/client/notifications/notificationsget_test.go') diff --git a/internal/api/client/notifications/notificationsget_test.go b/internal/api/client/notifications/notificationsget_test.go index 97d0e854b..5a6f83959 100644 --- a/internal/api/client/notifications/notificationsget_test.go +++ b/internal/api/client/notifications/notificationsget_test.go @@ -248,6 +248,45 @@ func (suite *NotificationsTestSuite) TestGetNotificationsIncludeOneType() { } } +// Test including an unknown notification type, it should be ignored. +func (suite *NotificationsTestSuite) TestGetNotificationsIncludeUnknownType() { + testAccount := suite.testAccounts["local_account_1"] + testToken := suite.testTokens["local_account_1"] + testUser := suite.testUsers["local_account_1"] + + suite.addMoreNotifications(testAccount) + + maxID := "" + minID := "" + limit := 10 + types := []string{"favourite", "something.weird"} + excludeTypes := []string(nil) + expectedHTTPStatus := http.StatusOK + expectedBody := "" + + notifications, _, err := suite.getNotifications( + testAccount, + testToken, + testUser, + maxID, + minID, + limit, + types, + excludeTypes, + expectedHTTPStatus, + expectedBody, + ) + if err != nil { + suite.FailNow(err.Error()) + } + + // This should only include the fav notification. + suite.Len(notifications, 1) + for _, notification := range notifications { + suite.Equal("favourite", notification.Type) + } +} + func TestBookmarkTestSuite(t *testing.T) { suite.Run(t, new(NotificationsTestSuite)) } -- cgit v1.2.3