@@ -31,9 +31,11 @@ func TestNotificationsForUser(t *testing.T) {
3131 statuses := []NotificationStatus {NotificationStatusRead , NotificationStatusUnread }
3232 notfs , err := NotificationsForUser (user , statuses , 1 , 10 )
3333 assert .NoError (t , err )
34- if assert .Len (t , notfs , 1 ) {
34+ if assert .Len (t , notfs , 2 ) {
3535 assert .EqualValues (t , 2 , notfs [0 ].ID )
3636 assert .EqualValues (t , user .ID , notfs [0 ].UserID )
37+ assert .EqualValues (t , 4 , notfs [1 ].ID )
38+ assert .EqualValues (t , user .ID , notfs [1 ].UserID )
3739 }
3840}
3941
@@ -57,12 +59,12 @@ func TestNotification_GetIssue(t *testing.T) {
5759
5860func TestGetNotificationCount (t * testing.T ) {
5961 assert .NoError (t , PrepareTestDatabase ())
60- user := AssertExistsAndLoadBean (t , & User {ID : 2 }).(* User )
61- cnt , err := GetNotificationCount (user , NotificationStatusUnread )
62+ user := AssertExistsAndLoadBean (t , & User {ID : 1 }).(* User )
63+ cnt , err := GetNotificationCount (user , NotificationStatusRead )
6264 assert .NoError (t , err )
6365 assert .EqualValues (t , 0 , cnt )
6466
65- cnt , err = GetNotificationCount (user , NotificationStatusRead )
67+ cnt , err = GetNotificationCount (user , NotificationStatusUnread )
6668 assert .NoError (t , err )
6769 assert .EqualValues (t , 1 , cnt )
6870}
@@ -79,3 +81,21 @@ func TestSetNotificationStatus(t *testing.T) {
7981 assert .Error (t , SetNotificationStatus (1 , user , NotificationStatusRead ))
8082 assert .Error (t , SetNotificationStatus (NonexistentID , user , NotificationStatusRead ))
8183}
84+
85+ func TestUpdateNotificationStatuses (t * testing.T ) {
86+ assert .NoError (t , PrepareTestDatabase ())
87+ user := AssertExistsAndLoadBean (t , & User {ID : 2 }).(* User )
88+ notfUnread := AssertExistsAndLoadBean (t ,
89+ & Notification {UserID : user .ID , Status : NotificationStatusUnread }).(* Notification )
90+ notfRead := AssertExistsAndLoadBean (t ,
91+ & Notification {UserID : user .ID , Status : NotificationStatusRead }).(* Notification )
92+ notfPinned := AssertExistsAndLoadBean (t ,
93+ & Notification {UserID : user .ID , Status : NotificationStatusPinned }).(* Notification )
94+ assert .NoError (t , UpdateNotificationStatuses (user , NotificationStatusUnread , NotificationStatusRead ))
95+ AssertExistsAndLoadBean (t ,
96+ & Notification {ID : notfUnread .ID , Status : NotificationStatusRead })
97+ AssertExistsAndLoadBean (t ,
98+ & Notification {ID : notfRead .ID , Status : NotificationStatusRead })
99+ AssertExistsAndLoadBean (t ,
100+ & Notification {ID : notfPinned .ID , Status : NotificationStatusPinned })
101+ }
0 commit comments