[MM-17422] Added code to update, delete last bot_icon time in model.bot. (#12229)
Display LHS bot Icon in web app. As part of mentioned task, Added LastIconUpdate variable in model.bot to store last update time of icon. Also added code to update/delete value of the mentioned variable when setting/deleting bot icon.
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
f8d31def8e
Коммит
803a58f991
@@ -14,14 +14,15 @@ import (
|
||||
|
||||
func TestBotTrace(t *testing.T) {
|
||||
bot := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
require.Equal(t, map[string]interface{}{"user_id": bot.UserId}, bot.Trace())
|
||||
@@ -29,14 +30,15 @@ func TestBotTrace(t *testing.T) {
|
||||
|
||||
func TestBotClone(t *testing.T) {
|
||||
bot := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
clone := bot.Clone()
|
||||
@@ -59,154 +61,165 @@ func TestBotIsValid(t *testing.T) {
|
||||
{
|
||||
"bot with missing user id",
|
||||
&Bot{
|
||||
UserId: "",
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: "",
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot with invalid user id",
|
||||
&Bot{
|
||||
UserId: "invalid",
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: "invalid",
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot with missing username",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot with invalid username",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "a@",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "a@",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot with long description",
|
||||
&Bot{
|
||||
UserId: "",
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: strings.Repeat("x", 1025),
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: "",
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: strings.Repeat("x", 1025),
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot with missing creator id",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: "",
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: "",
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot without create at timestamp",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 0,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 0,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot without update at timestamp",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 0,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 0,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bot",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 0,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 0,
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"bot without description",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 0,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 0,
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"deleted bot",
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "a description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "a description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
true,
|
||||
},
|
||||
@@ -225,12 +238,13 @@ func TestBotIsValid(t *testing.T) {
|
||||
|
||||
func TestBotPreSave(t *testing.T) {
|
||||
bot := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
DeleteAt: 0,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 0,
|
||||
DeleteAt: 0,
|
||||
}
|
||||
|
||||
originalBot := &*bot
|
||||
@@ -246,13 +260,14 @@ func TestBotPreSave(t *testing.T) {
|
||||
|
||||
func TestBotPreUpdate(t *testing.T) {
|
||||
bot := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
DeleteAt: 0,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
DeleteAt: 0,
|
||||
}
|
||||
|
||||
originalBot := &*bot
|
||||
@@ -267,14 +282,15 @@ func TestBotPreUpdate(t *testing.T) {
|
||||
func TestBotEtag(t *testing.T) {
|
||||
t.Run("same etags", func(t *testing.T) {
|
||||
bot1 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
bot2 := bot1
|
||||
|
||||
@@ -283,48 +299,52 @@ func TestBotEtag(t *testing.T) {
|
||||
t.Run("different etags", func(t *testing.T) {
|
||||
t.Run("different user id", func(t *testing.T) {
|
||||
bot1 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
bot2 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: bot1.OwnerId,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: bot1.OwnerId,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
assert.NotEqual(t, bot1.Etag(), bot2.Etag())
|
||||
})
|
||||
t.Run("different update at", func(t *testing.T) {
|
||||
bot1 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
bot2 := &Bot{
|
||||
UserId: bot1.UserId,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: bot1.OwnerId,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 10,
|
||||
DeleteAt: 3,
|
||||
UserId: bot1.UserId,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: bot1.OwnerId,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 10,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
assert.NotEqual(t, bot1.Etag(), bot2.Etag())
|
||||
@@ -334,25 +354,27 @@ func TestBotEtag(t *testing.T) {
|
||||
|
||||
func TestBotToAndFromJson(t *testing.T) {
|
||||
bot1 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
bot2 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description 2",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 4,
|
||||
UpdateAt: 5,
|
||||
DeleteAt: 6,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description 2",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 5,
|
||||
CreateAt: 6,
|
||||
UpdateAt: 7,
|
||||
DeleteAt: 8,
|
||||
}
|
||||
|
||||
assert.Equal(t, bot1, BotFromJson(bytes.NewReader(bot1.ToJson())))
|
||||
@@ -376,38 +398,41 @@ func TestBotPatch(t *testing.T) {
|
||||
{
|
||||
"no update",
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
&BotPatch{},
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
},
|
||||
{
|
||||
"partial update",
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
&BotPatch{
|
||||
Username: sToP("new_username"),
|
||||
@@ -415,27 +440,29 @@ func TestBotPatch(t *testing.T) {
|
||||
Description: sToP("new description"),
|
||||
},
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
Username: "new_username",
|
||||
DisplayName: "display name",
|
||||
Description: "new description",
|
||||
OwnerId: creatorId1,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: userId1,
|
||||
Username: "new_username",
|
||||
DisplayName: "display name",
|
||||
Description: "new description",
|
||||
OwnerId: creatorId1,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
},
|
||||
{
|
||||
"full update",
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: userId1,
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: creatorId1,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
&BotPatch{
|
||||
Username: sToP("new_username"),
|
||||
@@ -443,14 +470,15 @@ func TestBotPatch(t *testing.T) {
|
||||
Description: sToP("new description"),
|
||||
},
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
Username: "new_username",
|
||||
DisplayName: "new display name",
|
||||
Description: "new description",
|
||||
OwnerId: creatorId1,
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: userId1,
|
||||
Username: "new_username",
|
||||
DisplayName: "new display name",
|
||||
Description: "new description",
|
||||
OwnerId: creatorId1,
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -482,25 +510,27 @@ func TestBotPatchToAndFromJson(t *testing.T) {
|
||||
|
||||
func TestUserFromBot(t *testing.T) {
|
||||
bot1 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
bot2 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username2",
|
||||
DisplayName: "display name 2",
|
||||
Description: "description 2",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 4,
|
||||
UpdateAt: 5,
|
||||
DeleteAt: 6,
|
||||
UserId: NewId(),
|
||||
Username: "username2",
|
||||
DisplayName: "display name 2",
|
||||
Description: "description 2",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 5,
|
||||
CreateAt: 6,
|
||||
UpdateAt: 7,
|
||||
DeleteAt: 8,
|
||||
}
|
||||
|
||||
assert.Equal(t, &User{
|
||||
@@ -549,14 +579,15 @@ func TestBotListToAndFromJson(t *testing.T) {
|
||||
"single item",
|
||||
BotList{
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -564,25 +595,27 @@ func TestBotListToAndFromJson(t *testing.T) {
|
||||
"multiple items",
|
||||
BotList{
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
},
|
||||
|
||||
&Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description 2",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 4,
|
||||
UpdateAt: 5,
|
||||
DeleteAt: 6,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description 2",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 5,
|
||||
CreateAt: 6,
|
||||
UpdateAt: 7,
|
||||
DeleteAt: 8,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -597,36 +630,39 @@ func TestBotListToAndFromJson(t *testing.T) {
|
||||
|
||||
func TestBotListEtag(t *testing.T) {
|
||||
bot1 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 2,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 3,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
bot1Updated := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 1,
|
||||
UpdateAt: 10,
|
||||
DeleteAt: 3,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 1,
|
||||
CreateAt: 2,
|
||||
UpdateAt: 10,
|
||||
DeleteAt: 4,
|
||||
}
|
||||
|
||||
bot2 := &Bot{
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
CreateAt: 4,
|
||||
UpdateAt: 5,
|
||||
DeleteAt: 6,
|
||||
UserId: NewId(),
|
||||
Username: "username",
|
||||
DisplayName: "display name",
|
||||
Description: "description",
|
||||
OwnerId: NewId(),
|
||||
LastIconUpdate: 5,
|
||||
CreateAt: 6,
|
||||
UpdateAt: 7,
|
||||
DeleteAt: 8,
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
|
||||
Ссылка в новой задаче
Block a user