[MM-14779] Investigate flaky TestExportGMandDMChannels (#10534)
* fix flaky test by sorting by Type and also change helper to increase precision in CreateAt * better strategy is to get a smaller number * user nanonseconds as milisenconds proved to be a bit problematic for unit tests * revert changes in helper function and create posts in a more controled way * use the original value * make post instantiation more clear
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
7bde0378cd
Коммит
02bd35247b
@@ -354,7 +354,7 @@ func TestExportGMandDMChannels(t *testing.T) {
|
||||
channels = result.Data.([]*model.DirectChannelForExport)
|
||||
|
||||
// Adding some deteminism so its possible to assert on slice index
|
||||
sort.Slice(channels, func(i, j int) bool { return channels[i].CreateAt > channels[j].CreateAt })
|
||||
sort.Slice(channels, func(i, j int) bool { return channels[i].Type > channels[j].Type })
|
||||
assert.Equal(t, 2, len(channels))
|
||||
assert.ElementsMatch(t, []string{th1.BasicUser.Username, user1.Username, user2.Username}, *channels[0].Members)
|
||||
assert.ElementsMatch(t, []string{th1.BasicUser.Username, th1.BasicUser2.Username}, *channels[1].Members)
|
||||
@@ -377,11 +377,34 @@ func TestExportDMandGMPost(t *testing.T) {
|
||||
gmMembers := []string{th1.BasicUser.Username, user1.Username, user2.Username}
|
||||
|
||||
// DM posts
|
||||
th1.CreatePost(dmChannel)
|
||||
th1.CreatePost(dmChannel)
|
||||
p1 := &model.Post{
|
||||
ChannelId: dmChannel.Id,
|
||||
Message: "aa" + model.NewId() + "a",
|
||||
UserId: th1.BasicUser.Id,
|
||||
}
|
||||
th1.App.CreatePost(p1, dmChannel, false)
|
||||
|
||||
p2 := &model.Post{
|
||||
ChannelId: dmChannel.Id,
|
||||
Message: "bb" + model.NewId() + "a",
|
||||
UserId: th1.BasicUser.Id,
|
||||
}
|
||||
th1.App.CreatePost(p2, dmChannel, false)
|
||||
|
||||
// GM posts
|
||||
th1.CreatePost(gmChannel)
|
||||
th1.CreatePost(gmChannel)
|
||||
p3 := &model.Post{
|
||||
ChannelId: gmChannel.Id,
|
||||
Message: "cc" + model.NewId() + "a",
|
||||
UserId: th1.BasicUser.Id,
|
||||
}
|
||||
th1.App.CreatePost(p3, gmChannel, false)
|
||||
|
||||
p4 := &model.Post{
|
||||
ChannelId: gmChannel.Id,
|
||||
Message: "dd" + model.NewId() + "a",
|
||||
UserId: th1.BasicUser.Id,
|
||||
}
|
||||
th1.App.CreatePost(p4, gmChannel, false)
|
||||
|
||||
result := <-th1.App.Srv.Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts := result.Data.([]*model.DirectPostForExport)
|
||||
@@ -409,7 +432,7 @@ func TestExportDMandGMPost(t *testing.T) {
|
||||
posts = result.Data.([]*model.DirectPostForExport)
|
||||
|
||||
// Adding some deteminism so its possible to assert on slice index
|
||||
sort.Slice(posts, func(i, j int) bool { return posts[i].CreateAt > posts[j].CreateAt })
|
||||
sort.Slice(posts, func(i, j int) bool { return posts[i].Message > posts[j].Message })
|
||||
assert.Equal(t, 4, len(posts))
|
||||
assert.ElementsMatch(t, gmMembers, *posts[0].ChannelMembers)
|
||||
assert.ElementsMatch(t, gmMembers, *posts[1].ChannelMembers)
|
||||
|
||||
Ссылка в новой задаче
Block a user