summaryrefslogtreecommitdiffstats
path: root/model/channel_view_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-09-29 11:45:59 -0400
committerChristopher Speller <crspeller@gmail.com>2017-09-29 08:45:59 -0700
commit8b9dbb86133ff0fd6002a391268383d1593918ca (patch)
treeb8399f2bae881afe12f3bdb34ec725e97307144a /model/channel_view_test.go
parent5e50d3f4612dc8e6dffeff268f024a3d383a329c (diff)
downloadchat-8b9dbb86133ff0fd6002a391268383d1593918ca.tar.gz
chat-8b9dbb86133ff0fd6002a391268383d1593918ca.tar.bz2
chat-8b9dbb86133ff0fd6002a391268383d1593918ca.zip
PLT-7404 Return viewed at times in view channel API response (#7428)
* Return viewed at times in view channel API response * Updated transaction to read and write once * Remove transaction and only update if new value greater than older
Diffstat (limited to 'model/channel_view_test.go')
-rw-r--r--model/channel_view_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/model/channel_view_test.go b/model/channel_view_test.go
new file mode 100644
index 000000000..fac455a74
--- /dev/null
+++ b/model/channel_view_test.go
@@ -0,0 +1,38 @@
+// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestChannelViewJson(t *testing.T) {
+ o := ChannelView{ChannelId: NewId(), PrevChannelId: NewId()}
+ json := o.ToJson()
+ ro := ChannelViewFromJson(strings.NewReader(json))
+
+ if o.ChannelId != ro.ChannelId {
+ t.Fatal("ChannelIdIds do not match")
+ }
+
+ if o.PrevChannelId != ro.PrevChannelId {
+ t.Fatal("PrevChannelIds do not match")
+ }
+}
+
+func TestChannelViewResponseJson(t *testing.T) {
+ id := NewId()
+ o := ChannelViewResponse{Status: "OK", LastViewedAtTimes: map[string]int64{id: 12345}}
+ json := o.ToJson()
+ ro := ChannelViewResponseFromJson(strings.NewReader(json))
+
+ if o.Status != ro.Status {
+ t.Fatal("ChannelIdIds do not match")
+ }
+
+ if o.LastViewedAtTimes[id] != ro.LastViewedAtTimes[id] {
+ t.Fatal("LastViewedAtTimes do not match")
+ }
+}