From f82667f3b86202dafff3a2a4ea56aec74c80316d Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 27 Oct 2016 12:24:30 -0300 Subject: PLT-4430 improve slow channel switching (#4331) * PLT-4430 improve slow channel switching * Update client side unit tests * Convert getChannelsUnread to getMyChannelMembers and address other feedback * Pull channel members on websocket reconnect --- store/sql_channel_store_test.go | 55 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'store/sql_channel_store_test.go') diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go index d80d54d52..8a51d2ae3 100644 --- a/store/sql_channel_store_test.go +++ b/store/sql_channel_store_test.go @@ -305,14 +305,14 @@ func TestChannelStoreDelete(t *testing.T) { cresult := <-store.Channel().GetChannels(o1.TeamId, m1.UserId) list := cresult.Data.(*model.ChannelList) - if len(list.Channels) != 1 { + if len(*list) != 1 { t.Fatal("invalid number of channels") } cresult = <-store.Channel().GetMoreChannels(o1.TeamId, m1.UserId) list = cresult.Data.(*model.ChannelList) - if len(list.Channels) != 1 { + if len(*list) != 1 { t.Fatal("invalid number of channels") } } @@ -514,7 +514,7 @@ func TestChannelStoreGetChannels(t *testing.T) { cresult := <-store.Channel().GetChannels(o1.TeamId, m1.UserId) list := cresult.Data.(*model.ChannelList) - if list.Channels[0].Id != o1.Id { + if (*list)[0].Id != o1.Id { t.Fatal("missing channel") } @@ -614,11 +614,11 @@ func TestChannelStoreGetMoreChannels(t *testing.T) { cresult := <-store.Channel().GetMoreChannels(o1.TeamId, m1.UserId) list := cresult.Data.(*model.ChannelList) - if len(list.Channels) != 1 { + if len(*list) != 1 { t.Fatal("wrong list") } - if list.Channels[0].Name != o3.Name { + if (*list)[0].Name != o3.Name { t.Fatal("missing channel") } @@ -688,6 +688,51 @@ func TestChannelStoreGetChannelCounts(t *testing.T) { } } +func TestChannelStoreGetMembersForUser(t *testing.T) { + Setup() + + t1 := model.Team{} + t1.DisplayName = "Name" + t1.Name = model.NewId() + t1.Email = model.NewId() + "@nowhere.com" + t1.Type = model.TEAM_OPEN + Must(store.Team().Save(&t1)) + + o1 := model.Channel{} + o1.TeamId = t1.Id + o1.DisplayName = "Channel1" + o1.Name = "a" + model.NewId() + "b" + o1.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&o1)) + + o2 := model.Channel{} + o2.TeamId = o1.TeamId + o2.DisplayName = "Channel2" + o2.Name = "a" + model.NewId() + "b" + o2.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&o2)) + + m1 := model.ChannelMember{} + m1.ChannelId = o1.Id + m1.UserId = model.NewId() + m1.NotifyProps = model.GetDefaultChannelNotifyProps() + Must(store.Channel().SaveMember(&m1)) + + m2 := model.ChannelMember{} + m2.ChannelId = o2.Id + m2.UserId = m1.UserId + m2.NotifyProps = model.GetDefaultChannelNotifyProps() + Must(store.Channel().SaveMember(&m2)) + + cresult := <-store.Channel().GetMembersForUser(o1.TeamId, m1.UserId) + members := cresult.Data.(*model.ChannelMembers) + + // no unread messages + if len(*members) != 2 { + t.Fatal("wrong number of members") + } +} + func TestChannelStoreUpdateLastViewedAt(t *testing.T) { Setup() -- cgit v1.2.3-1-g7c22