Files
mattermost/model/channel_member_test.go
Agniva De Sarker a49e78b1d4 MM-22051: Remove FromJson part 2 (#17981)
```release-note
Removed the following functions:
ChannelsWithCountFromJson
ChannelFromJson
ChannelPatchFromJson
ChannelModerationsFromJson
ChannelModerationsPatchFromJson
ChannelMemberCountsByGroupFromJson
ChannelCountsFromJson
ChannelDataFromJson
ChannelListFromJson
ChannelSliceFromJson
ChannelListWithTeamDataFromJson
ChannelMembersFromJson
ChannelUnreadFromJson
ChannelUnreadAtFromJson
ChannelMemberFromJson
ChannelSearchFromJson
SidebarCategoryFromJson
SidebarCategoriesFromJson
OrderedSidebarCategoriesFromJson
```

https://mattermost.atlassian.net/browse/MM-22051
2021-07-23 12:35:59 +05:30

41 lines
1.0 KiB
Go

// 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")
}