[MM-29217] Remove Posts.ParentId (#17923)

Этот коммит содержится в:
Claudio Costa
2021-08-17 10:25:22 +02:00
коммит произвёл GitHub
родитель 757dc96461
Коммит d181ae9262
34 изменённых файлов: 22 добавлений и 211 удалений

Просмотреть файл

@@ -181,7 +181,6 @@ func createPost(ss store.Store, channelId, userId, rootId, parentId string) *mod
m.ChannelId = channelId
m.UserId = userId
m.RootId = rootId
m.ParentId = parentId
m.Message = "zz" + model.NewId() + "b"
p, _ := ss.Post().Save(&m)
return p
@@ -604,51 +603,6 @@ func TestCheckPostsFileInfoIntegrity(t *testing.T) {
})
}
func TestCheckPostsPostsParentIdIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
store := ss.(*SqlStore)
dbmap := store.GetMaster()
t.Run("should generate a report with no records", func(t *testing.T) {
result := checkPostsPostsParentIdIntegrity(store)
require.NoError(t, result.Err)
data := result.Data.(model.RelationalIntegrityCheckData)
require.Empty(t, data.Records)
})
t.Run("should generate a report with no records", func(t *testing.T) {
root := createPost(ss, model.NewId(), model.NewId(), "", "")
parent := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
result := checkPostsPostsParentIdIntegrity(store)
require.NoError(t, result.Err)
data := result.Data.(model.RelationalIntegrityCheckData)
require.Empty(t, data.Records)
dbmap.Delete(parent)
dbmap.Delete(root)
dbmap.Delete(post)
})
t.Run("should generate a report with one record", func(t *testing.T) {
root := createPost(ss, model.NewId(), model.NewId(), "", "")
parent := createPost(ss, model.NewId(), model.NewId(), root.Id, root.Id)
parentId := parent.Id
post := createPost(ss, model.NewId(), model.NewId(), root.Id, parent.Id)
dbmap.Delete(parent)
result := checkPostsPostsParentIdIntegrity(store)
require.NoError(t, result.Err)
data := result.Data.(model.RelationalIntegrityCheckData)
require.Len(t, data.Records, 1)
require.Equal(t, model.OrphanedRecord{
ParentId: &parentId,
ChildId: &post.Id,
}, data.Records[0])
dbmap.Delete(root)
dbmap.Delete(post)
})
})
}
func TestCheckPostsPostsRootIdIntegrity(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
store := ss.(*SqlStore)