Fix staticcheck errors from _test.go files (#18033)

Automatic Merge
Этот коммит содержится в:
dave
2021-08-10 13:15:03 +08:00
коммит произвёл GitHub
родитель 3f01129ddf
Коммит 16c2925ba2
28 изменённых файлов: 70 добавлений и 88 удалений

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

@@ -5453,12 +5453,10 @@ func TestGetThreadsForUser(t *testing.T) {
var rootIds []*model.Post
for i := 0; i < 30; i++ {
time.Sleep(1)
rpost, resp := Client.CreatePost(&model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
CheckNoError(t, resp)
CheckCreatedStatus(t, resp)
rootIds = append(rootIds, rpost)
time.Sleep(1)
_, resp2 := Client.CreatePost(&model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
CheckNoError(t, resp2)
CheckCreatedStatus(t, resp2)
@@ -5482,10 +5480,8 @@ func TestGetThreadsForUser(t *testing.T) {
var rootIds []*model.Post
for i := 0; i < 30; i++ {
time.Sleep(1)
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: fmt.Sprintf("testMsg-%d", i)})
rootIds = append(rootIds, rpost)
time.Sleep(1)
postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: fmt.Sprintf("testReply-%d", i), RootId: rpost.Id})
}
rootId := rootIds[15].Id // middle point
@@ -5822,14 +5818,11 @@ func TestThreadCounts(t *testing.T) {
// create a post by regular user
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
// reply with another
time.Sleep(1)
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
// create another post by regular user
time.Sleep(1)
rpost2, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testMsg1"})
// reply with another 2 times
time.Sleep(1)
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply2", RootId: rpost2.Id})
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply22", RootId: rpost2.Id})
@@ -5868,12 +5861,10 @@ func TestSingleThreadGet(t *testing.T) {
// create a post by regular user
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
// reply with another
time.Sleep(1)
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
// create another thread to check that we are not returning it by mistake
rpost2, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testMsg2"})
time.Sleep(1)
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel2.Id, Message: "testReply", RootId: rpost2.Id})
// regular user should have two threads with 3 replies total
@@ -5982,7 +5973,6 @@ func TestReadThreads(t *testing.T) {
CheckNoError(t, resp)
require.Len(t, uss.Threads, 1)
time.Sleep(1)
resp = th.Client.UpdateThreadsReadForUser(th.BasicUser.Id, th.BasicTeam.Id)
CheckNoError(t, resp)
CheckOKStatus(t, resp)
@@ -6044,9 +6034,7 @@ func TestMarkThreadUnreadMentionCount(t *testing.T) {
require.Nil(t, appErr)
rpost, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg @" + th.BasicUser2.Username})
time.Sleep(1)
reply, _ := postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply1", RootId: rpost.Id})
time.Sleep(1)
postAndCheck(t, Client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply2", RootId: rpost.Id})
th.SystemAdminClient.UpdateThreadReadForUser(th.BasicUser2.Id, th.BasicTeam.Id, rpost.Id, model.GetMillis())