Этот коммит содержится в:
Christopher Speller
2020-01-06 11:17:19 -08:00
коммит произвёл GitHub
родитель 5c6bdc357a
Коммит 45565cb81f
2 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@@ -519,6 +519,10 @@ func modifyChannelCmdF(command *cobra.Command, args []string) error {
}
user := getUserFromUserArg(a, username)
if user == nil {
return fmt.Errorf("Unable to find user: '%v'", username)
}
if _, err := a.UpdateChannelPrivacy(channel, user); err != nil {
return errors.Wrapf(err, "Failed to update channel ('%s') privacy", args[0])
}

Просмотреть файл

@@ -227,3 +227,30 @@ func Test_searchChannelCmdF(t *testing.T) {
})
}
}
func TestModifyChannel(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
channel1 := th.CreatePrivateChannel()
channel2 := th.CreatePrivateChannel()
th.CheckCommand(t, "channel", "modify", "--public", th.BasicTeam.Name+":"+channel1.Name, "--username", th.BasicUser2.Email)
res, err := th.App.Srv.Store.Channel().Get(channel1.Id, false)
require.Nil(t, err)
assert.Equal(t, model.CHANNEL_OPEN, res.Type)
// should fail because user doesn't exist
require.Error(t, th.RunCommand(t, "channel", "modify", "--public", th.BasicTeam.Name+":"+channel2.Name, "--username", "idonotexist"))
pchannel1 := th.CreatePublicChannel()
pchannel2 := th.CreatePublicChannel()
th.CheckCommand(t, "channel", "modify", "--private", th.BasicTeam.Name+":"+pchannel1.Name, "--username", th.BasicUser2.Email)
res, err = th.App.Srv.Store.Channel().Get(pchannel1.Id, false)
require.Nil(t, err)
assert.Equal(t, model.CHANNEL_PRIVATE, res.Type)
// should fail because user doesn't exist
require.Error(t, th.RunCommand(t, "channel", "modify", "--private", th.BasicTeam.Name+":"+pchannel2.Name, "--username", "idonotexist"))
}