[release-10.11] Restrict group_constrained to channels that support group sync (#36916)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
56098dd6f0
Коммит
beaa59db54
@@ -35,6 +35,47 @@ func TestChannelPatch(t *testing.T) {
|
||||
require.Equal(t, *p.GroupConstrained, *o.GroupConstrained)
|
||||
}
|
||||
|
||||
func TestChannelSupportsGroupSync(t *testing.T) {
|
||||
require.True(t, (&Channel{Type: ChannelTypeOpen}).SupportsGroupSync())
|
||||
require.True(t, (&Channel{Type: ChannelTypePrivate}).SupportsGroupSync())
|
||||
require.False(t, (&Channel{Type: ChannelTypeDirect}).SupportsGroupSync())
|
||||
require.False(t, (&Channel{Type: ChannelTypeGroup}).SupportsGroupSync())
|
||||
}
|
||||
|
||||
func TestChannelIsValidGroupConstrained(t *testing.T) {
|
||||
base := Channel{
|
||||
Id: NewId(),
|
||||
CreateAt: GetMillis(),
|
||||
UpdateAt: GetMillis(),
|
||||
DisplayName: "x",
|
||||
Name: "valid-name",
|
||||
Header: "h",
|
||||
Purpose: "p",
|
||||
}
|
||||
|
||||
t.Run("group_constrained is allowed on public and private channels", func(t *testing.T) {
|
||||
c := base
|
||||
c.GroupConstrained = NewPointer(true)
|
||||
|
||||
c.Type = ChannelTypeOpen
|
||||
require.Nil(t, c.IsValid())
|
||||
|
||||
c.Type = ChannelTypePrivate
|
||||
require.Nil(t, c.IsValid())
|
||||
})
|
||||
|
||||
t.Run("group_constrained is rejected on direct and group channels", func(t *testing.T) {
|
||||
c := base
|
||||
c.GroupConstrained = NewPointer(true)
|
||||
|
||||
c.Type = ChannelTypeDirect
|
||||
require.NotNil(t, c.IsValid())
|
||||
|
||||
c.Type = ChannelTypeGroup
|
||||
require.NotNil(t, c.IsValid())
|
||||
})
|
||||
}
|
||||
|
||||
func TestChannelIsValid(t *testing.T) {
|
||||
o := Channel{}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user