github.com/wgh-/mattermost-server@v4.8.0-rc2+incompatible/model/channel_view_test.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package model 5 6 import ( 7 "strings" 8 "testing" 9 ) 10 11 func TestChannelViewJson(t *testing.T) { 12 o := ChannelView{ChannelId: NewId(), PrevChannelId: NewId()} 13 json := o.ToJson() 14 ro := ChannelViewFromJson(strings.NewReader(json)) 15 16 if o.ChannelId != ro.ChannelId { 17 t.Fatal("ChannelIdIds do not match") 18 } 19 20 if o.PrevChannelId != ro.PrevChannelId { 21 t.Fatal("PrevChannelIds do not match") 22 } 23 } 24 25 func TestChannelViewResponseJson(t *testing.T) { 26 id := NewId() 27 o := ChannelViewResponse{Status: "OK", LastViewedAtTimes: map[string]int64{id: 12345}} 28 json := o.ToJson() 29 ro := ChannelViewResponseFromJson(strings.NewReader(json)) 30 31 if o.Status != ro.Status { 32 t.Fatal("ChannelIdIds do not match") 33 } 34 35 if o.LastViewedAtTimes[id] != ro.LastViewedAtTimes[id] { 36 t.Fatal("LastViewedAtTimes do not match") 37 } 38 }