summaryrefslogtreecommitdiff
path: root/internal/db/bundb/notification_test.go
diff options
context:
space:
mode:
authorLibravatar Artémis <diane@artemix.org>2022-08-01 11:13:49 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-01 11:13:49 +0200
commit4fdbef04b4ae41e6193d4f4416c83edf91e1bfb7 (patch)
treef28b7d40c38ee6b83ae5ff386cf25dc55ed0e157 /internal/db/bundb/notification_test.go
parentserve HEAD requests via the fileserver (#735) (diff)
downloadgotosocial-4fdbef04b4ae41e6193d4f4416c83edf91e1bfb7.tar.xz
[feature] Implemented notification clear (#720)
* Implemented notification clear * Added the cache clear mechanism * added multi user check test
Diffstat (limited to 'internal/db/bundb/notification_test.go')
-rw-r--r--internal/db/bundb/notification_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/db/bundb/notification_test.go b/internal/db/bundb/notification_test.go
index b14704dcc..d822c9a28 100644
--- a/internal/db/bundb/notification_test.go
+++ b/internal/db/bundb/notification_test.go
@@ -118,6 +118,35 @@ func (suite *NotificationTestSuite) TestGetNotificationsWithoutSpam() {
}
}
+func (suite *NotificationTestSuite) TestClearNotificationsWithSpam() {
+ suite.spamNotifs()
+ testAccount := suite.testAccounts["local_account_1"]
+ err := suite.db.ClearNotifications(context.Background(), testAccount.ID)
+ suite.NoError(err)
+
+ notifications, err := suite.db.GetNotifications(context.Background(), testAccount.ID, 20, "ZZZZZZZZZZZZZZZZZZZZZZZZZZ", "00000000000000000000000000")
+ suite.NoError(err)
+ suite.NotNil(notifications)
+ suite.Empty(notifications)
+}
+
+func (suite *NotificationTestSuite) TestClearNotificationsWithTwoAccounts() {
+ suite.spamNotifs()
+ testAccount := suite.testAccounts["local_account_1"]
+ err := suite.db.ClearNotifications(context.Background(), testAccount.ID)
+ suite.NoError(err)
+
+ notifications, err := suite.db.GetNotifications(context.Background(), testAccount.ID, 20, "ZZZZZZZZZZZZZZZZZZZZZZZZZZ", "00000000000000000000000000")
+ suite.NoError(err)
+ suite.NotNil(notifications)
+ suite.Empty(notifications)
+
+ notif := []*gtsmodel.Notification{}
+ err = suite.db.GetAll(context.Background(), &notif)
+ suite.NoError(err)
+ suite.NotEmpty(notif)
+}
+
func TestNotificationTestSuite(t *testing.T) {
suite.Run(t, new(NotificationTestSuite))
}