@@ -285,7 +285,7 @@ func TestCredGetAll(t *testing.T) {
285285
286286func TestUserUnreadCount (t * testing.T ) {
287287 uids := []types.Uid {types .ParseUserId ("usr" + users [1 ].Id ), types .ParseUserId ("usr" + users [2 ].Id )}
288- expected := map [types.Uid ]int {uids [0 ]: 5 , uids [1 ]: 100 }
288+ expected := map [types.Uid ]int {uids [0 ]: 0 , uids [1 ]: 166 }
289289 counts , err := adp .UserUnreadCount (uids ... )
290290 if err != nil {
291291 t .Fatal (err )
@@ -296,17 +296,21 @@ func TestUserUnreadCount(t *testing.T) {
296296
297297 for uid , unread := range counts {
298298 if expected [uid ] != unread {
299- t .Error (mismatchErrorString ("UnreadCount" , uid , unread ))
299+ t .Error (mismatchErrorString ("UnreadCount" , unread , expected [ uid ] ))
300300 }
301301 }
302302
303- // Test not found
304- counts , err = adp .UserUnreadCount (types .ParseUserId ("dummyuserid" ))
303+ // Test not found (even if the account is not found, the call must return one record).
304+ uid := types .ParseUserId ("dummyuserid" )
305+ counts , err = adp .UserUnreadCount (uid )
305306 if err != nil {
306307 t .Fatal (err )
307308 }
308- if len (counts ) != 0 {
309- t .Error (mismatchErrorString ("UnreadCount length (dummy)" , len (counts ), 0 ))
309+ if len (counts ) != 1 {
310+ t .Error (mismatchErrorString ("UnreadCount length (dummy)" , len (counts ), 1 ))
311+ }
312+ if counts [uid ] != 0 {
313+ t .Error (mismatchErrorString ("Non-zero UnreadCount (dummy)" , counts [uid ], 0 ))
310314 }
311315}
312316
0 commit comments