@@ -31,9 +31,11 @@ func TestNotificationsForUser(t *testing.T) {
31
31
statuses := []NotificationStatus {NotificationStatusRead , NotificationStatusUnread }
32
32
notfs , err := NotificationsForUser (user , statuses , 1 , 10 )
33
33
assert .NoError (t , err )
34
- if assert .Len (t , notfs , 1 ) {
34
+ if assert .Len (t , notfs , 2 ) {
35
35
assert .EqualValues (t , 2 , notfs [0 ].ID )
36
36
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 )
37
39
}
38
40
}
39
41
@@ -57,12 +59,12 @@ func TestNotification_GetIssue(t *testing.T) {
57
59
58
60
func TestGetNotificationCount (t * testing.T ) {
59
61
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 )
62
64
assert .NoError (t , err )
63
65
assert .EqualValues (t , 0 , cnt )
64
66
65
- cnt , err = GetNotificationCount (user , NotificationStatusRead )
67
+ cnt , err = GetNotificationCount (user , NotificationStatusUnread )
66
68
assert .NoError (t , err )
67
69
assert .EqualValues (t , 1 , cnt )
68
70
}
@@ -79,3 +81,21 @@ func TestSetNotificationStatus(t *testing.T) {
79
81
assert .Error (t , SetNotificationStatus (1 , user , NotificationStatusRead ))
80
82
assert .Error (t , SetNotificationStatus (NonexistentID , user , NotificationStatusRead ))
81
83
}
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