[MM-14719] convert users to bots through cmd (#10672)
* [MM-14719] convert users to bots through cmd * address review comments, add / fix unit tests * change command from "modify" to "convert"; review comments * code review comments, clean up
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
dce6cb601f
Коммит
fc15eda37f
10
model/bot.go
10
model/bot.go
@@ -172,6 +172,16 @@ func UserFromBot(b *Bot) *User {
|
||||
}
|
||||
}
|
||||
|
||||
// BotFromUser returns a bot model given a user model
|
||||
func BotFromUser(u *User) *Bot {
|
||||
return &Bot{
|
||||
OwnerId: u.Id,
|
||||
UserId: u.Id,
|
||||
Username: u.Username,
|
||||
DisplayName: u.GetDisplayName(SHOW_USERNAME),
|
||||
}
|
||||
}
|
||||
|
||||
// BotListFromJson deserializes a list of bots from json.
|
||||
func BotListFromJson(data io.Reader) BotList {
|
||||
var bots BotList
|
||||
|
||||
@@ -517,6 +517,23 @@ func TestUserFromBot(t *testing.T) {
|
||||
}, UserFromBot(bot2))
|
||||
}
|
||||
|
||||
func TestBotFromUser(t *testing.T) {
|
||||
user := &User{
|
||||
Id: NewId(),
|
||||
Username: "username",
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
}
|
||||
|
||||
assert.Equal(t, &Bot{
|
||||
OwnerId: user.Id,
|
||||
UserId: user.Id,
|
||||
Username: "username",
|
||||
DisplayName: "username",
|
||||
}, BotFromUser(user))
|
||||
}
|
||||
|
||||
func TestBotListToAndFromJson(t *testing.T) {
|
||||
testCases := []struct {
|
||||
Description string
|
||||
|
||||
Ссылка в новой задаче
Block a user