MM-57391: improve error message (#26630)

The error reporte when moving channels and failing has been improved to show
that the problem was the repeated name on the team.
The error message has been unified with MM-53756

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
pacop
2024-04-22 09:40:08 +02:00
коммит произвёл GitHub
родитель e73a9512f6
Коммит 9e6da03ab1
4 изменённых файлов: 33 добавлений и 8 удалений

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

@@ -4801,6 +4801,29 @@ func TestMoveChannel(t *testing.T) {
require.Equal(t, team2.Id, ch.TeamId)
})
t.Run("Should return custom error with repeated channel", func(t *testing.T) {
channelT1 := &model.Channel{
DisplayName: "repeated",
Name: "repeated",
Type: model.ChannelTypePrivate,
TeamId: team1.Id,
}
channelT1, _, err := th.Client.CreateChannel(context.TODO(), channelT1)
require.NoError(t, err)
channelT2 := &model.Channel{
DisplayName: "repeated",
Name: "repeated",
Type: model.ChannelTypePrivate,
TeamId: team2.Id,
}
_, _, err = th.Client.CreateChannel(context.TODO(), channelT2)
require.NoError(t, err)
_, _, err = th.SystemAdminClient.MoveChannel(context.Background(), channelT1.Id, team2.Id, false)
require.EqualError(t, err, "A channel with that name already exists on the same team.")
})
t.Run("Should move private channel", func(t *testing.T) {
channel := th.CreatePrivateChannel()
ch, _, err := th.SystemAdminClient.MoveChannel(context.Background(), channel.Id, team1.Id, false)