github.com/adacta-ru/mattermost-server/v6@v6.0.0/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 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestChannelViewJson(t *testing.T) { 14 o := ChannelView{ChannelId: NewId(), PrevChannelId: NewId()} 15 json := o.ToJson() 16 ro := ChannelViewFromJson(strings.NewReader(json)) 17 18 assert.Equal(t, o.ChannelId, ro.ChannelId, "ChannelIdIds do not match") 19 assert.Equal(t, o.PrevChannelId, ro.PrevChannelId, "PrevChannelIds do not match") 20 } 21 22 func TestChannelViewResponseJson(t *testing.T) { 23 id := NewId() 24 o := ChannelViewResponse{Status: "OK", LastViewedAtTimes: map[string]int64{id: 12345}} 25 json := o.ToJson() 26 ro := ChannelViewResponseFromJson(strings.NewReader(json)) 27 28 assert.Equal(t, o.Status, ro.Status, "ChannelIdIds do not match") 29 assert.Equal(t, o.LastViewedAtTimes[id], ro.LastViewedAtTimes[id], "LastViewedAtTimes do not match") 30 }