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
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
5e50d3f461
Коммит
8b9dbb8613
38
model/channel_view_test.go
Обычный файл
38
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")
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user