коммит произвёл
GitHub
родитель
236d46ecc6
Коммит
f2c955b3d3
@@ -18,6 +18,11 @@ import (
|
||||
|
||||
// CreateBot creates the given bot and corresponding user.
|
||||
func (a *App) CreateBot(c *request.Context, bot *model.Bot) (*model.Bot, *model.AppError) {
|
||||
vErr := bot.IsValidCreate()
|
||||
if vErr != nil {
|
||||
return nil, vErr
|
||||
}
|
||||
|
||||
user, nErr := a.Srv().Store.User().Save(model.UserFromBot(bot))
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestCreateBot(t *testing.T) {
|
||||
OwnerId: th.BasicUser.Id,
|
||||
})
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, "model.user.is_valid.username.app_error", err.Id)
|
||||
require.Equal(t, "model.bot.is_valid.username.app_error", err.Id)
|
||||
})
|
||||
|
||||
t.Run("relative to bot", func(t *testing.T) {
|
||||
@@ -55,6 +55,18 @@ func TestCreateBot(t *testing.T) {
|
||||
require.Nil(t, bot)
|
||||
require.Equal(t, "model.user.is_valid.email.app_error", err.Id)
|
||||
})
|
||||
|
||||
t.Run("username missing", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
bot, err := th.App.CreateBot(th.Context, &model.Bot{
|
||||
Description: "a bot",
|
||||
OwnerId: th.BasicUser.Id,
|
||||
})
|
||||
require.NotNil(t, err)
|
||||
require.Nil(t, bot)
|
||||
require.Equal(t, "model.bot.is_valid.username.app_error", err.Id)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("create bot", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user