mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-19135 Migrate tests from "model/channel_member_test.go" to… (#12651)
This commit is contained in:
committed by
Eli Yukelzon
parent
7239f8da60
commit
ade6044441
@@ -6,6 +6,8 @@ package model
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestChannelMemberJson(t *testing.T) {
|
||||
@@ -13,22 +15,16 @@ func TestChannelMemberJson(t *testing.T) {
|
||||
json := o.ToJson()
|
||||
ro := ChannelMemberFromJson(strings.NewReader(json))
|
||||
|
||||
if o.ChannelId != ro.ChannelId {
|
||||
t.Fatal("Ids do not match")
|
||||
}
|
||||
require.Equal(t, o.ChannelId, ro.ChannelId, "ids do not match")
|
||||
}
|
||||
|
||||
func TestChannelMemberIsValid(t *testing.T) {
|
||||
o := ChannelMember{}
|
||||
|
||||
if err := o.IsValid(); err == nil {
|
||||
t.Fatal("should be invalid")
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
|
||||
o.ChannelId = NewId()
|
||||
if err := o.IsValid(); err == nil {
|
||||
t.Fatal("should be invalid")
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
|
||||
o.NotifyProps = GetDefaultChannelNotifyProps()
|
||||
o.UserId = NewId()
|
||||
@@ -40,34 +36,22 @@ func TestChannelMemberIsValid(t *testing.T) {
|
||||
}*/
|
||||
|
||||
o.NotifyProps["desktop"] = "junk"
|
||||
if err := o.IsValid(); err == nil {
|
||||
t.Fatal("should be invalid")
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
|
||||
o.NotifyProps["desktop"] = "123456789012345678901"
|
||||
if err := o.IsValid(); err == nil {
|
||||
t.Fatal("should be invalid")
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
|
||||
o.NotifyProps["desktop"] = CHANNEL_NOTIFY_ALL
|
||||
if err := o.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
|
||||
o.NotifyProps["mark_unread"] = "123456789012345678901"
|
||||
if err := o.IsValid(); err == nil {
|
||||
t.Fatal("should be invalid")
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
|
||||
o.NotifyProps["mark_unread"] = CHANNEL_MARK_UNREAD_ALL
|
||||
if err := o.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
|
||||
o.Roles = ""
|
||||
if err := o.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Error(t, o.IsValid(), "should be invalid")
|
||||
}
|
||||
|
||||
func TestChannelUnreadJson(t *testing.T) {
|
||||
@@ -75,11 +59,6 @@ func TestChannelUnreadJson(t *testing.T) {
|
||||
json := o.ToJson()
|
||||
ro := ChannelUnreadFromJson(strings.NewReader(json))
|
||||
|
||||
if o.TeamId != ro.TeamId {
|
||||
t.Fatal("Team Ids do not match")
|
||||
}
|
||||
|
||||
if o.MentionCount != ro.MentionCount {
|
||||
t.Fatal("MentionCount do not match")
|
||||
}
|
||||
require.Equal(t, o.TeamId, ro.TeamId, "team Ids do not match")
|
||||
require.Equal(t, o.MentionCount, ro.MentionCount, "mention count do not match")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user