MM-19135 Migrate tests from "model/channel_member_test.go" to… (#12651)
Этот коммит содержится в:
коммит произвёл
Eli Yukelzon
родитель
7239f8da60
Коммит
ade6044441
@@ -6,6 +6,8 @@ package model
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestChannelMemberJson(t *testing.T) {
|
func TestChannelMemberJson(t *testing.T) {
|
||||||
@@ -13,22 +15,16 @@ func TestChannelMemberJson(t *testing.T) {
|
|||||||
json := o.ToJson()
|
json := o.ToJson()
|
||||||
ro := ChannelMemberFromJson(strings.NewReader(json))
|
ro := ChannelMemberFromJson(strings.NewReader(json))
|
||||||
|
|
||||||
if o.ChannelId != ro.ChannelId {
|
require.Equal(t, o.ChannelId, ro.ChannelId, "ids do not match")
|
||||||
t.Fatal("Ids do not match")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestChannelMemberIsValid(t *testing.T) {
|
func TestChannelMemberIsValid(t *testing.T) {
|
||||||
o := ChannelMember{}
|
o := ChannelMember{}
|
||||||
|
|
||||||
if err := o.IsValid(); err == nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal("should be invalid")
|
|
||||||
}
|
|
||||||
|
|
||||||
o.ChannelId = NewId()
|
o.ChannelId = NewId()
|
||||||
if err := o.IsValid(); err == nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal("should be invalid")
|
|
||||||
}
|
|
||||||
|
|
||||||
o.NotifyProps = GetDefaultChannelNotifyProps()
|
o.NotifyProps = GetDefaultChannelNotifyProps()
|
||||||
o.UserId = NewId()
|
o.UserId = NewId()
|
||||||
@@ -40,34 +36,22 @@ func TestChannelMemberIsValid(t *testing.T) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
o.NotifyProps["desktop"] = "junk"
|
o.NotifyProps["desktop"] = "junk"
|
||||||
if err := o.IsValid(); err == nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal("should be invalid")
|
|
||||||
}
|
|
||||||
|
|
||||||
o.NotifyProps["desktop"] = "123456789012345678901"
|
o.NotifyProps["desktop"] = "123456789012345678901"
|
||||||
if err := o.IsValid(); err == nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal("should be invalid")
|
|
||||||
}
|
|
||||||
|
|
||||||
o.NotifyProps["desktop"] = CHANNEL_NOTIFY_ALL
|
o.NotifyProps["desktop"] = CHANNEL_NOTIFY_ALL
|
||||||
if err := o.IsValid(); err != nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
o.NotifyProps["mark_unread"] = "123456789012345678901"
|
o.NotifyProps["mark_unread"] = "123456789012345678901"
|
||||||
if err := o.IsValid(); err == nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal("should be invalid")
|
|
||||||
}
|
|
||||||
|
|
||||||
o.NotifyProps["mark_unread"] = CHANNEL_MARK_UNREAD_ALL
|
o.NotifyProps["mark_unread"] = CHANNEL_MARK_UNREAD_ALL
|
||||||
if err := o.IsValid(); err != nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
o.Roles = ""
|
o.Roles = ""
|
||||||
if err := o.IsValid(); err != nil {
|
require.Error(t, o.IsValid(), "should be invalid")
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestChannelUnreadJson(t *testing.T) {
|
func TestChannelUnreadJson(t *testing.T) {
|
||||||
@@ -75,11 +59,6 @@ func TestChannelUnreadJson(t *testing.T) {
|
|||||||
json := o.ToJson()
|
json := o.ToJson()
|
||||||
ro := ChannelUnreadFromJson(strings.NewReader(json))
|
ro := ChannelUnreadFromJson(strings.NewReader(json))
|
||||||
|
|
||||||
if o.TeamId != ro.TeamId {
|
require.Equal(t, o.TeamId, ro.TeamId, "team Ids do not match")
|
||||||
t.Fatal("Team Ids do not match")
|
require.Equal(t, o.MentionCount, ro.MentionCount, "mention count do not match")
|
||||||
}
|
|
||||||
|
|
||||||
if o.MentionCount != ro.MentionCount {
|
|
||||||
t.Fatal("MentionCount do not match")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user