diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-12-21 16:35:01 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-12-21 16:35:01 -0500 |
commit | ba6e370ca71abacaa30234cb164427d27c86df13 (patch) | |
tree | 2379b6dab897deef1226f66772b8f05e0bb08f9c /api/channel_test.go | |
parent | 139cb52c99ac525f44a280803447bbbd88369f23 (diff) | |
download | chat-ba6e370ca71abacaa30234cb164427d27c86df13.tar.gz chat-ba6e370ca71abacaa30234cb164427d27c86df13.tar.bz2 chat-ba6e370ca71abacaa30234cb164427d27c86df13.zip |
PLT-5012 Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API (#4840)
* Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API
* Remove preference DB writes
Diffstat (limited to 'api/channel_test.go')
-rw-r--r-- | api/channel_test.go | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/api/channel_test.go b/api/channel_test.go index ae4573c9c..d24a6d603 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -724,8 +724,9 @@ func TestGetChannel(t *testing.T) { t.Fatal("cache should be empty") } - if _, err := Client.UpdateLastViewedAt(channel2.Id, true); err != nil { - t.Fatal(err) + view := model.ChannelView{ChannelId: channel2.Id, PrevChannelId: channel1.Id} + if _, resp := Client.ViewChannel(view); resp.Error != nil { + t.Fatal(resp.Error) } if resp, err := Client.GetChannel(channel1.Id, ""); err != nil { @@ -1735,3 +1736,44 @@ func TestGetChannelByName(t *testing.T) { t.Fatal("Should fail due to not enough permissions") } } + +func TestViewChannel(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + + view := model.ChannelView{ + ChannelId: th.BasicChannel.Id, + } + + if _, resp := Client.ViewChannel(view); resp.Error != nil { + t.Fatal(resp.Error) + } + + view.PrevChannelId = th.BasicChannel.Id + + if _, resp := Client.ViewChannel(view); resp.Error != nil { + t.Fatal(resp.Error) + } + + view.PrevChannelId = "" + view.Time = 1234567890 + + if _, resp := Client.ViewChannel(view); resp.Error != nil { + t.Fatal(resp.Error) + } + + view.PrevChannelId = "junk" + view.Time = 0 + + if _, resp := Client.ViewChannel(view); resp.Error != nil { + t.Fatal(resp.Error) + } + + rdata := Client.Must(Client.GetChannel(th.BasicChannel.Id, "")).Data.(*model.ChannelData) + + if rdata.Channel.TotalMsgCount != rdata.Member.MsgCount { + t.Log(rdata.Channel.TotalMsgCount) + t.Log(rdata.Member.MsgCount) + t.Fatal("message counts don't match") + } +} |