summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-11 09:02:58 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-11 12:11:35 -0400
commit9f57ed5bf12d2d3a4cb143985c80646b877a1706 (patch)
treee2d4550a463afff98522c1231909f4215f8c61d8 /store/sql_channel_store_test.go
parent4ec76e059cddc127c35bf758f7fda7c7636c8d70 (diff)
downloadchat-9f57ed5bf12d2d3a4cb143985c80646b877a1706.tar.gz
chat-9f57ed5bf12d2d3a4cb143985c80646b877a1706.tar.bz2
chat-9f57ed5bf12d2d3a4cb143985c80646b877a1706.zip
added store unit test for GetChannelCounts
Diffstat (limited to 'store/sql_channel_store_test.go')
-rw-r--r--store/sql_channel_store_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index b14883843..dabe39904 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -462,6 +462,53 @@ func TestChannelStoreGetMoreChannels(t *testing.T) {
}
}
+func TestChannelStoreGetChannelCounts(t *testing.T) {
+ Setup()
+
+ o2 := model.Channel{}
+ o2.TeamId = model.NewId()
+ o2.DisplayName = "Channel2"
+ o2.Name = "a" + model.NewId() + "b"
+ o2.Type = model.CHANNEL_OPEN
+ Must(store.Channel().Save(&o2))
+
+ o1 := model.Channel{}
+ o1.TeamId = model.NewId()
+ o1.DisplayName = "Channel1"
+ o1.Name = "a" + model.NewId() + "b"
+ o1.Type = model.CHANNEL_OPEN
+ Must(store.Channel().Save(&o1))
+
+ m1 := model.ChannelMember{}
+ m1.ChannelId = o1.Id
+ m1.UserId = model.NewId()
+ m1.NotifyLevel = model.CHANNEL_NOTIFY_ALL
+ Must(store.Channel().SaveMember(&m1))
+
+ m2 := model.ChannelMember{}
+ m2.ChannelId = o1.Id
+ m2.UserId = model.NewId()
+ m2.NotifyLevel = model.CHANNEL_NOTIFY_ALL
+ Must(store.Channel().SaveMember(&m2))
+
+ m3 := model.ChannelMember{}
+ m3.ChannelId = o2.Id
+ m3.UserId = model.NewId()
+ m3.NotifyLevel = model.CHANNEL_NOTIFY_ALL
+ Must(store.Channel().SaveMember(&m3))
+
+ cresult := <-store.Channel().GetChannelCounts(o1.TeamId, m1.UserId)
+ counts := cresult.Data.(*model.ChannelCounts)
+
+ if len(counts.Counts) != 1 {
+ t.Fatal("wrong number of counts")
+ }
+
+ if len(counts.UpdateTimes) != 1 {
+ t.Fatal("wrong number of update times")
+ }
+}
+
func TestChannelStoreUpdateLastViewedAt(t *testing.T) {
Setup()