summaryrefslogtreecommitdiffstats
path: root/store/sql_team_store_test.go
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-12-19 10:05:46 -0300
committerJoram Wilander <jwawilander@gmail.com>2016-12-19 08:05:46 -0500
commit999d1553e1ce45adf58f6082b160bc1147dc592b (patch)
tree369a9b7f46dd44d136a79a050469429169433cec /store/sql_team_store_test.go
parent3ce2ce9dc882ed962dc3ce7550bdb07963f376b6 (diff)
downloadchat-999d1553e1ce45adf58f6082b160bc1147dc592b.tar.gz
chat-999d1553e1ce45adf58f6082b160bc1147dc592b.tar.bz2
chat-999d1553e1ce45adf58f6082b160bc1147dc592b.zip
PLT-4167 Team Sidebar (#4569)
* PLT-4167 Team Sidebar * Address feedback from PM * change route from my_members to members * bug fixes * Updating styles for teams sidebar (#4681) * Added PM changes * Fix corner cases * Addressing feedback * use two different endpoints * Bug fixes * Rename model and client functions, using preferences to store last team and channel viewed * Fix mobile notification count and closing the team sidebar * unit test, fixed bad merge and retrieve from cached when available * bug fixes * use id for last channel in preferences, query optimization * Updating multi team css (#4830)
Diffstat (limited to 'store/sql_team_store_test.go')
-rw-r--r--store/sql_team_store_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/store/sql_team_store_test.go b/store/sql_team_store_test.go
index 0e472a961..5e6abd102 100644
--- a/store/sql_team_store_test.go
+++ b/store/sql_team_store_test.go
@@ -529,3 +529,50 @@ func TestTeamStoreMemberCount(t *testing.T) {
}
}
}
+
+func TestMyTeamMembersUnread(t *testing.T) {
+ Setup()
+
+ teamId1 := model.NewId()
+ teamId2 := model.NewId()
+
+ uid := model.NewId()
+ m1 := &model.TeamMember{TeamId: teamId1, UserId: uid}
+ m2 := &model.TeamMember{TeamId: teamId2, UserId: uid}
+ Must(store.Team().SaveMember(m1))
+ Must(store.Team().SaveMember(m2))
+
+ c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN}
+ Must(store.Channel().Save(c1))
+ c2 := &model.Channel{TeamId: m2.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN}
+ Must(store.Channel().Save(c2))
+
+ cm1 := &model.ChannelMember{ChannelId: c1.Id, UserId: m1.UserId, NotifyProps: model.GetDefaultChannelNotifyProps()}
+ Must(store.Channel().SaveMember(cm1))
+ cm2 := &model.ChannelMember{ChannelId: c2.Id, UserId: m2.UserId, NotifyProps: model.GetDefaultChannelNotifyProps()}
+ Must(store.Channel().SaveMember(cm2))
+
+ if r1 := <-store.Team().GetTeamsUnreadForUser("", uid); r1.Err != nil {
+ t.Fatal(r1.Err)
+ } else {
+ ms := r1.Data.([]*model.TeamUnread)
+
+ if len(ms) != 2 {
+ t.Fatal("Should be the unreads for all the teams")
+ }
+ }
+
+ if r2 := <-store.Team().GetTeamsUnreadForUser(teamId1, uid); r2.Err != nil {
+ t.Fatal(r2.Err)
+ } else {
+ ms := r2.Data.([]*model.TeamUnread)
+
+ if len(ms) != 1 {
+ t.Fatal("Should be the unreads for just one team")
+ }
+ }
+
+ if r1 := <-store.Team().RemoveAllMembersByUser(uid); r1.Err != nil {
+ t.Fatal(r1.Err)
+ }
+}