[MM-27622] Publish messages as SystemBot when a user is required (#17598)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c6d94c8696
Коммит
72c86448b9
@@ -915,6 +915,44 @@ func TestDeleteBotIconImage(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetSystemBot(t *testing.T) {
|
||||
t.Run("An error should be returned if there are no sysadmins in the instance", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
require.Nil(t, th.App.PermanentDeleteAllUsers(th.Context))
|
||||
|
||||
_, err := th.App.GetSystemBot()
|
||||
require.NotNil(t, err)
|
||||
require.Equal(t, "app.bot.get_system_bot.empty_admin_list.app_error", err.Id)
|
||||
})
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("The bot should be created the first time it's retrieved", func(t *testing.T) {
|
||||
// assert no bot with username exists
|
||||
_, err := th.App.GetUserByUsername(model.BOT_SYSTEM_BOT_USERNAME)
|
||||
require.NotNil(t, err)
|
||||
|
||||
bot, err := th.App.GetSystemBot()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, bot.Username, model.BOT_SYSTEM_BOT_USERNAME)
|
||||
})
|
||||
|
||||
t.Run("The bot should be correctly retrieved if it exists already", func(t *testing.T) {
|
||||
// assert that the bot is now present
|
||||
botUser, err := th.App.GetUserByUsername(model.BOT_SYSTEM_BOT_USERNAME)
|
||||
require.Nil(t, err)
|
||||
require.True(t, botUser.IsBot)
|
||||
|
||||
bot, err := th.App.GetSystemBot()
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, bot.Username, model.BOT_SYSTEM_BOT_USERNAME)
|
||||
require.Equal(t, bot.UserId, botUser.Id)
|
||||
})
|
||||
}
|
||||
|
||||
func sToP(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user