[MM-45868] Add teamId to Threads table (#20915)
* Add teamId to Threads table * Get rid of multiple teamId reads * Fix failed test * Add teamId to standard queries * Fix linter * Get teamId from db
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6ac0faf99e
Коммит
fab9d350c7
@@ -6894,11 +6894,19 @@ func testChannelStoreGetPinnedPosts(t *testing.T, ss store.Store) {
|
||||
require.Empty(t, pl.Posts, "wasn't supposed to return posts")
|
||||
|
||||
t.Run("with correct ReplyCount", func(t *testing.T) {
|
||||
channelId := model.NewId()
|
||||
teamId := model.NewId()
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "DisplayName",
|
||||
Name: "channel" + model.NewId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
}, -1)
|
||||
require.NoError(t, err)
|
||||
|
||||
userId := model.NewId()
|
||||
|
||||
post1, err := ss.Post().Save(&model.Post{
|
||||
ChannelId: channelId,
|
||||
ChannelId: channel.Id,
|
||||
UserId: userId,
|
||||
Message: "message",
|
||||
IsPinned: true,
|
||||
@@ -6907,7 +6915,7 @@ func testChannelStoreGetPinnedPosts(t *testing.T, ss store.Store) {
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
post2, err := ss.Post().Save(&model.Post{
|
||||
ChannelId: channelId,
|
||||
ChannelId: channel.Id,
|
||||
UserId: userId,
|
||||
Message: "message",
|
||||
IsPinned: true,
|
||||
@@ -6916,7 +6924,7 @@ func testChannelStoreGetPinnedPosts(t *testing.T, ss store.Store) {
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
post3, err := ss.Post().Save(&model.Post{
|
||||
ChannelId: channelId,
|
||||
ChannelId: channel.Id,
|
||||
UserId: userId,
|
||||
RootId: post1.Id,
|
||||
Message: "message",
|
||||
@@ -6925,7 +6933,7 @@ func testChannelStoreGetPinnedPosts(t *testing.T, ss store.Store) {
|
||||
require.NoError(t, err)
|
||||
time.Sleep(time.Millisecond)
|
||||
|
||||
posts, err := ss.Channel().GetPinnedPosts(channelId)
|
||||
posts, err := ss.Channel().GetPinnedPosts(channel.Id)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, posts.Posts, 3)
|
||||
require.Equal(t, posts.Posts[post1.Id].ReplyCount, int64(1))
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -106,8 +106,17 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
require.Equal(t, int64(2), thread.ReplyCount)
|
||||
require.ElementsMatch(t, model.StringArray{newPosts[0].UserId, newPosts[1].UserId}, thread.Participants)
|
||||
|
||||
teamId := model.NewId()
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "DisplayName1",
|
||||
Name: "channel" + model.NewId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
}, -1)
|
||||
require.NoError(t, err)
|
||||
|
||||
o5 := model.Post{}
|
||||
o5.ChannelId = model.NewId()
|
||||
o5.ChannelId = channel.Id
|
||||
o5.UserId = model.NewId()
|
||||
o5.RootId = newPosts[0].Id
|
||||
o5.Message = NewTestId()
|
||||
@@ -141,9 +150,18 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("Update reply should update the UpdateAt of the thread", func(t *testing.T) {
|
||||
teamId := model.NewId()
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "DisplayName",
|
||||
Name: "channel" + model.NewId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
}, -1)
|
||||
require.NoError(t, err)
|
||||
|
||||
rootPost := model.Post{}
|
||||
rootPost.RootId = model.NewId()
|
||||
rootPost.ChannelId = model.NewId()
|
||||
rootPost.ChannelId = channel.Id
|
||||
rootPost.UserId = model.NewId()
|
||||
rootPost.Message = NewTestId()
|
||||
|
||||
@@ -188,8 +206,17 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("Deleting reply should update the thread", func(t *testing.T) {
|
||||
teamId := model.NewId()
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "DisplayName",
|
||||
Name: "channel" + model.NewId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
}, -1)
|
||||
require.NoError(t, err)
|
||||
|
||||
o1 := model.Post{}
|
||||
o1.ChannelId = model.NewId()
|
||||
o1.ChannelId = channel.Id
|
||||
o1.UserId = model.NewId()
|
||||
o1.Message = NewTestId()
|
||||
rootPost, err := ss.Post().Save(&o1)
|
||||
@@ -240,8 +267,17 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
})
|
||||
|
||||
t.Run("Deleting root post should delete the thread", func(t *testing.T) {
|
||||
teamId := model.NewId()
|
||||
channel, err := ss.Channel().Save(&model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "DisplayName",
|
||||
Name: "channel" + model.NewId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
}, -1)
|
||||
require.NoError(t, err)
|
||||
|
||||
rootPost := model.Post{}
|
||||
rootPost.ChannelId = model.NewId()
|
||||
rootPost.ChannelId = channel.Id
|
||||
rootPost.UserId = model.NewId()
|
||||
rootPost.Message = NewTestId()
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user