diff options
author | 2024-11-27 18:22:45 +0100 | |
---|---|---|
committer | 2024-11-27 17:22:45 +0000 | |
commit | 65917f5bb98f1c0a0ce7285c284d25ea843c02c7 (patch) | |
tree | 9dd34f87dd8f5fd08ff22e98ba26556486eb6a97 /internal/api/client/notifications/notificationsget_test.go | |
parent | pull in ncruces/go-sqlite3 v0.20.3 with tetratelabs/wazero v1.8.2 (#3574) (diff) | |
download | gotosocial-65917f5bb98f1c0a0ce7285c284d25ea843c02c7.tar.xz |
[bugfix] Log + ignore unknown notification types (#3577)
* [bugfix] Log + ignore unknown notification types
* pass context to ParseNotificationTypes
Diffstat (limited to 'internal/api/client/notifications/notificationsget_test.go')
-rw-r--r-- | internal/api/client/notifications/notificationsget_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
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)) } |