forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
channel_member_test.go
40 lines (27 loc) · 1 KB
/
channel_member_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestChannelMemberIsValid(t *testing.T) {
o := ChannelMember{}
require.NotNil(t, o.IsValid(), "should be invalid")
o.ChannelId = NewId()
require.NotNil(t, o.IsValid(), "should be invalid")
o.NotifyProps = GetDefaultChannelNotifyProps()
o.UserId = NewId()
o.NotifyProps["desktop"] = "junk"
require.NotNil(t, o.IsValid(), "should be invalid")
o.NotifyProps["desktop"] = "123456789012345678901"
require.NotNil(t, o.IsValid(), "should be invalid")
o.NotifyProps["desktop"] = ChannelNotifyAll
require.Nil(t, o.IsValid(), "should be valid")
o.NotifyProps["mark_unread"] = "123456789012345678901"
require.NotNil(t, o.IsValid(), "should be invalid")
o.NotifyProps["mark_unread"] = ChannelMarkUnreadAll
require.Nil(t, o.IsValid(), "should be valid")
o.Roles = ""
require.Nil(t, o.IsValid(), "should be invalid")
}