Move cluster, webhub and store out of Server (#20899)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-10-06 11:04:21 +03:00
коммит произвёл GitHub
родитель 203df2f537
Коммит 5e69c6b02f
222 изменённых файлов: 9093 добавлений и 7710 удалений

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

@@ -225,7 +225,7 @@ func TestCreateUserWithToken(t *testing.T) {
app.TokenTypeTeamInvitation,
model.MapToJSON(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
require.NoError(t, th.App.Srv().Store.Token().Save(token))
require.NoError(t, th.App.Srv().Store().Token().Save(token))
ruser, resp, err := th.Client.CreateUserWithToken(&user, token.Token)
require.NoError(t, err)
@@ -235,7 +235,7 @@ func TestCreateUserWithToken(t *testing.T) {
require.Equal(t, user.Nickname, ruser.Nickname)
require.Equal(t, model.SystemUserRoleId, ruser.Roles, "should clear roles")
CheckUserSanitization(t, ruser)
_, err = th.App.Srv().Store.Token().GetByToken(token.Token)
_, err = th.App.Srv().Store().Token().GetByToken(token.Token)
require.Error(t, err, "The token must be deleted after being used")
teams, appErr := th.App.GetTeamsForUser(ruser.Id)
@@ -250,7 +250,7 @@ func TestCreateUserWithToken(t *testing.T) {
app.TokenTypeTeamInvitation,
model.MapToJSON(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
require.NoError(t, th.App.Srv().Store.Token().Save(token))
require.NoError(t, th.App.Srv().Store().Token().Save(token))
ruser, resp, err := client.CreateUserWithToken(&user, token.Token)
require.NoError(t, err)
@@ -260,7 +260,7 @@ func TestCreateUserWithToken(t *testing.T) {
require.Equal(t, user.Nickname, ruser.Nickname)
require.Equal(t, model.SystemUserRoleId, ruser.Roles, "should clear roles")
CheckUserSanitization(t, ruser)
_, err = th.App.Srv().Store.Token().GetByToken(token.Token)
_, err = th.App.Srv().Store().Token().GetByToken(token.Token)
require.Error(t, err, "The token must be deleted after being used")
teams, appErr := th.App.GetTeamsForUser(ruser.Id)
@@ -275,7 +275,7 @@ func TestCreateUserWithToken(t *testing.T) {
app.TokenTypeTeamInvitation,
model.MapToJSON(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
require.NoError(t, th.App.Srv().Store.Token().Save(token))
require.NoError(t, th.App.Srv().Store().Token().Save(token))
defer th.App.DeleteToken(token)
_, _, err := th.Client.CreateUserWithToken(&user, "")
@@ -292,7 +292,7 @@ func TestCreateUserWithToken(t *testing.T) {
model.MapToJSON(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
token.CreateAt = past49Hours
require.NoError(t, th.App.Srv().Store.Token().Save(token))
require.NoError(t, th.App.Srv().Store().Token().Save(token))
defer th.App.DeleteToken(token)
_, resp, err := th.Client.CreateUserWithToken(&user, token.Token)
@@ -323,7 +323,7 @@ func TestCreateUserWithToken(t *testing.T) {
app.TokenTypeTeamInvitation,
model.MapToJSON(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
require.NoError(t, th.App.Srv().Store.Token().Save(token))
require.NoError(t, th.App.Srv().Store().Token().Save(token))
defer th.App.DeleteToken(token)
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false })
@@ -344,7 +344,7 @@ func TestCreateUserWithToken(t *testing.T) {
app.TokenTypeTeamInvitation,
model.MapToJSON(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
require.NoError(t, th.App.Srv().Store.Token().Save(token))
require.NoError(t, th.App.Srv().Store().Token().Save(token))
defer th.App.DeleteToken(token)
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false })
@@ -362,7 +362,7 @@ func TestCreateUserWithToken(t *testing.T) {
app.TokenTypeTeamInvitation,
model.MapToJSON(map[string]string{"teamId": th.BasicTeam.Id, "email": user.Email}),
)
require.NoError(t, th.App.Srv().Store.Token().Save(token))
require.NoError(t, th.App.Srv().Store().Token().Save(token))
enableOpenServer := th.App.Config().TeamSettings.EnableOpenServer
defer func() {
@@ -379,7 +379,7 @@ func TestCreateUserWithToken(t *testing.T) {
require.Equal(t, user.Nickname, ruser.Nickname)
require.Equal(t, model.SystemUserRoleId, ruser.Roles, "should clear roles")
CheckUserSanitization(t, ruser)
_, err = th.App.Srv().Store.Token().GetByToken(token.Token)
_, err = th.App.Srv().Store().Token().GetByToken(token.Token)
require.Error(t, err, "The token must be deleted after be used")
})
}
@@ -1665,7 +1665,7 @@ func TestGetTotalUsersStat(t *testing.T) {
th := Setup(t)
defer th.TearDown()
total, _ := th.Server.Store.User().Count(model.UserCountOptions{
total, _ := th.Server.Store().User().Count(model.UserCountOptions{
IncludeDeleted: false,
IncludeBotAccounts: true,
})
@@ -1934,7 +1934,7 @@ func TestUpdateUserAuth(t *testing.T) {
user := th.CreateUser()
th.LinkUserToTeam(user, team)
_, err := th.App.Srv().Store.User().VerifyEmail(user.Id, user.Email)
_, err := th.App.Srv().Store().User().VerifyEmail(user.Id, user.Email)
require.NoError(t, err)
userAuth := &model.UserAuth{}
@@ -1967,7 +1967,7 @@ func TestUpdateUserAuth(t *testing.T) {
// Regular user can not use endpoint
user2 := th.CreateUser()
th.LinkUserToTeam(user2, team)
_, err = th.App.Srv().Store.User().VerifyEmail(user2.Id, user2.Email)
_, err = th.App.Srv().Store().User().VerifyEmail(user2.Id, user2.Email)
require.NoError(t, err)
th.SystemAdminClient.Login(user2.Email, "passwd1")
@@ -2100,11 +2100,11 @@ func TestPermanentDeleteAllUsers(t *testing.T) {
require.Nil(t, appErr)
// Check that we have users and posts in the database
users, err := th.App.Srv().Store.User().GetAll()
users, err := th.App.Srv().Store().User().GetAll()
require.NoError(t, err)
require.Greater(t, len(users), 0)
postCount, err := th.App.Srv().Store.Post().AnalyticsPostCount(&model.PostCountOptions{})
postCount, err := th.App.Srv().Store().Post().AnalyticsPostCount(&model.PostCountOptions{})
require.NoError(t, err)
require.Greater(t, postCount, int64(0))
@@ -2113,11 +2113,11 @@ func TestPermanentDeleteAllUsers(t *testing.T) {
require.NoError(t, err)
// Check that both user and post tables are empty
users, err = th.App.Srv().Store.User().GetAll()
users, err = th.App.Srv().Store().User().GetAll()
require.NoError(t, err)
require.Len(t, users, 0)
postCount, err = th.App.Srv().Store.Post().AnalyticsPostCount(&model.PostCountOptions{})
postCount, err = th.App.Srv().Store().Post().AnalyticsPostCount(&model.PostCountOptions{})
require.NoError(t, err)
require.Equal(t, postCount, int64(0))
@@ -2233,7 +2233,7 @@ func TestUpdateUserActive(t *testing.T) {
require.NoError(t, err)
authData := model.NewId()
_, err := th.App.Srv().Store.User().UpdateAuthData(user.Id, "random", &authData, "", true)
_, err := th.App.Srv().Store().User().UpdateAuthData(user.Id, "random", &authData, "", true)
require.NoError(t, err)
_, err = client.UpdateUserActive(user.Id, false)
@@ -2472,7 +2472,7 @@ func TestGetUsersWithoutTeam(t *testing.T) {
})
require.NoError(t, err)
th.LinkUserToTeam(user, th.BasicTeam)
defer th.App.Srv().Store.User().PermanentDelete(user.Id)
defer th.App.Srv().Store().User().PermanentDelete(user.Id)
user2, _, err := th.Client.CreateUser(&model.User{
Username: "a000000001" + model.NewId(),
@@ -2480,7 +2480,7 @@ func TestGetUsersWithoutTeam(t *testing.T) {
Password: "Password1",
})
require.NoError(t, err)
defer th.App.Srv().Store.User().PermanentDelete(user2.Id)
defer th.App.Srv().Store().User().PermanentDelete(user2.Id)
rusers, _, err := th.SystemAdminClient.GetUsersWithoutTeam(0, 100, "")
require.NoError(t, err)
@@ -2789,13 +2789,13 @@ func TestUserLoginMFAFlow(t *testing.T) {
assert.Nil(t, appErr)
// Fake user has MFA enabled
err := th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
err := th.Server.Store().User().UpdateMfaActive(th.BasicUser.Id, true)
require.NoError(t, err)
err = th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
err = th.Server.Store().User().UpdateMfaActive(th.BasicUser.Id, true)
require.NoError(t, err)
err = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
err = th.Server.Store().User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
require.NoError(t, err)
user, _, err := th.Client.Login(th.BasicUser.Email, th.BasicUser.Password)
@@ -2822,10 +2822,10 @@ func TestUserLoginMFAFlow(t *testing.T) {
assert.Nil(t, appErr)
// Fake user has MFA enabled
err := th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
err := th.Server.Store().User().UpdateMfaActive(th.BasicUser.Id, true)
require.NoError(t, err)
err = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
err = th.Server.Store().User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
require.NoError(t, err)
code := dgoogauth.ComputeCode(secret.Secret, time.Now().UTC().Unix()/30)
@@ -3006,7 +3006,7 @@ func TestResetPassword(t *testing.T) {
loc += 6
recoveryTokenString = resultsEmail.Body.Text[loc : loc+model.TokenSize]
}
recoveryToken, err := th.App.Srv().Store.Token().GetByToken(recoveryTokenString)
recoveryToken, err := th.App.Srv().Store().Token().GetByToken(recoveryTokenString)
require.NoError(t, err, "Recovery token not found (%s)", recoveryTokenString)
resp, err := th.Client.ResetPassword(recoveryToken.Token, "")
@@ -3036,7 +3036,7 @@ func TestResetPassword(t *testing.T) {
require.Error(t, err)
CheckBadRequestStatus(t, resp)
authData := model.NewId()
_, err = th.App.Srv().Store.User().UpdateAuthData(user.Id, "random", &authData, "", true)
_, err = th.App.Srv().Store().User().UpdateAuthData(user.Id, "random", &authData, "", true)
require.NoError(t, err)
th.TestForAllClients(t, func(t *testing.T, client *model.Client4) {
resp, err = client.SendPasswordResetEmail(user.Email)
@@ -3200,10 +3200,10 @@ func TestRevokeSessionsFromAllUsers(t *testing.T) {
th.Client.Login(user.Email, user.Password)
admin := th.SystemAdminUser
th.Client.Login(admin.Email, admin.Password)
sessions, err := th.Server.Store.Session().GetSessions(user.Id)
sessions, err := th.Server.Store().Session().GetSessions(user.Id)
require.NotEmpty(t, sessions)
require.NoError(t, err)
sessions, err = th.Server.Store.Session().GetSessions(admin.Id)
sessions, err = th.Server.Store().Session().GetSessions(admin.Id)
require.NotEmpty(t, sessions)
require.NoError(t, err)
_, err = th.Client.RevokeSessionsFromAllUsers()
@@ -3215,11 +3215,11 @@ func TestRevokeSessionsFromAllUsers(t *testing.T) {
require.Error(t, err)
CheckUnauthorizedStatus(t, resp)
sessions, err = th.Server.Store.Session().GetSessions(user.Id)
sessions, err = th.Server.Store().Session().GetSessions(user.Id)
require.Empty(t, sessions)
require.NoError(t, err)
sessions, err = th.Server.Store.Session().GetSessions(admin.Id)
sessions, err = th.Server.Store().Session().GetSessions(admin.Id)
require.Empty(t, sessions)
require.NoError(t, err)
@@ -3891,7 +3891,7 @@ func TestSwitchAccount(t *testing.T) {
th.LoginBasic()
fakeAuthData := model.NewId()
_, appErr := th.App.Srv().Store.User().UpdateAuthData(th.BasicUser.Id, model.UserAuthServiceGitlab, &fakeAuthData, th.BasicUser.Email, true)
_, appErr := th.App.Srv().Store().User().UpdateAuthData(th.BasicUser.Id, model.UserAuthServiceGitlab, &fakeAuthData, th.BasicUser.Email, true)
require.NoError(t, appErr)
sr = &model.SwitchRequest{
@@ -4978,7 +4978,7 @@ func TestGetUsersByStatus(t *testing.T) {
th.LinkUserToTeam(user, team)
th.AddUserToChannel(user, channel)
th.App.SaveAndBroadcastStatus(&model.Status{
th.App.Srv().Platform().SaveAndBroadcastStatus(&model.Status{
UserId: user.Id,
Status: status,
Manual: true,
@@ -5169,7 +5169,7 @@ func TestLoginLockout(t *testing.T) {
CheckErrorID(t, err, "api.user.check_user_login_attempts.too_many.app_error")
// Fake user has MFA enabled
err = th.Server.Store.User().UpdateMfaActive(th.BasicUser2.Id, true)
err = th.Server.Store().User().UpdateMfaActive(th.BasicUser2.Id, true)
require.NoError(t, err)
_, _, err = th.Client.LoginWithMFA(th.BasicUser2.Email, th.BasicUser2.Password, "000000")
CheckErrorID(t, err, "api.user.check_user_mfa.bad_code.app_error")
@@ -5183,7 +5183,7 @@ func TestLoginLockout(t *testing.T) {
CheckErrorID(t, err, "api.user.check_user_login_attempts.too_many.app_error")
// Fake user has MFA disabled
err = th.Server.Store.User().UpdateMfaActive(th.BasicUser2.Id, false)
err = th.Server.Store().User().UpdateMfaActive(th.BasicUser2.Id, false)
require.NoError(t, err)
//Check if lock is active
@@ -5512,7 +5512,7 @@ func TestPublishUserTyping(t *testing.T) {
})
})
th.Server.Busy.Set(time.Second * 10)
th.Server.Platform().Busy.Set(time.Second * 10)
t.Run("should return service unavailable for non-system admin user when triggering a typing event and server busy", func(t *testing.T) {
resp, err := th.Client.PublishUserTyping("invalid", tr)
@@ -5643,7 +5643,7 @@ func TestGetThreadsForUser(t *testing.T) {
require.NoError(t, err)
CheckCreatedStatus(t, resp)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
require.NoError(t, err)
@@ -5660,7 +5660,7 @@ func TestGetThreadsForUser(t *testing.T) {
require.NoError(t, err)
CheckCreatedStatus(t, resp)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{})
require.NoError(t, err)
@@ -5679,7 +5679,7 @@ func TestGetThreadsForUser(t *testing.T) {
require.NoError(t, err)
CheckCreatedStatus(t, resp)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
Extended: true,
@@ -5701,7 +5701,7 @@ func TestGetThreadsForUser(t *testing.T) {
require.NoError(t, err)
CheckCreatedStatus(t, resp)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
Deleted: false,
@@ -5744,7 +5744,7 @@ func TestGetThreadsForUser(t *testing.T) {
CheckCreatedStatus(t, resp)
}
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
Deleted: false,
@@ -5771,7 +5771,7 @@ func TestGetThreadsForUser(t *testing.T) {
rootIdBefore := rootIds[14].Id
rootIdAfter := rootIds[16].Id
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
Deleted: false,
@@ -5822,8 +5822,8 @@ func TestGetThreadsForUser(t *testing.T) {
CheckCreatedStatus(t, resp)
}
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
Deleted: false,
@@ -5858,8 +5858,8 @@ func TestGetThreadsForUser(t *testing.T) {
CheckCreatedStatus(t, resp)
}
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
uss, _, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
Deleted: false,
@@ -5881,7 +5881,7 @@ func TestGetThreadsForUser(t *testing.T) {
})
t.Run("setting both threadsOnly, and totalsOnly params is not allowed", func(t *testing.T) {
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
_, resp, err := th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
ThreadsOnly: true,
@@ -5966,8 +5966,8 @@ func TestThreadSocketEvents(t *testing.T) {
replyPost, appErr := th.App.CreatePostAsUser(th.Context, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply @" + th.BasicUser.Username, UserId: th.BasicUser2.Id, RootId: rpost.Id}, th.Context.Session().Id, false)
require.Nil(t, appErr)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser2.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser2.Id)
t.Run("Listed for update event", func(t *testing.T) {
var caught bool
@@ -6230,7 +6230,7 @@ func TestFollowThreads(t *testing.T) {
require.NoError(t, err)
CheckCreatedStatus(t, resp)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
var uss *model.Threads
uss, _, err = th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
Deleted: false,
@@ -6332,8 +6332,8 @@ func TestMaintainUnreadRepliesInThread(t *testing.T) {
})
client := th.Client
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
// create a post by regular user
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
@@ -6389,8 +6389,8 @@ func TestThreadCounts(t *testing.T) {
})
client := th.Client
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
// create a post by regular user
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
@@ -6409,7 +6409,7 @@ func TestThreadCounts(t *testing.T) {
})
// delete first thread
th.App.Srv().Store.Post().Delete(rpost.Id, model.GetMillis(), th.BasicUser.Id)
th.App.Srv().Store().Post().Delete(rpost.Id, model.GetMillis(), th.BasicUser.Id)
// we should now have 1 thread with 2 replies
checkThreadListReplies(t, th, th.Client, th.BasicUser.Id, 2, 1, &model.GetUserThreadsOpts{
@@ -6432,8 +6432,8 @@ func TestSingleThreadGet(t *testing.T) {
})
client := th.Client
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
// create a post by regular user
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
@@ -6489,8 +6489,8 @@ func TestMaintainUnreadMentionsInThread(t *testing.T) {
return uss, resp
}
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
// create regular post
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsg"})
@@ -6545,7 +6545,7 @@ func TestReadThreads(t *testing.T) {
_, resp, err = client.CreatePost(&model.Post{ChannelId: th.BasicChannel.Id, Message: "testReply", RootId: rpost.Id})
require.NoError(t, err)
CheckCreatedStatus(t, resp)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
var uss, uss2 *model.Threads
uss, _, err = th.Client.GetUserThreads(th.BasicUser.Id, th.BasicTeam.Id, model.GetUserThreadsOpts{
@@ -6567,8 +6567,8 @@ func TestReadThreads(t *testing.T) {
})
t.Run("1 thread by timestamp", func(t *testing.T) {
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsgC1"})
postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReplyC1", RootId: rpost.Id})
@@ -6595,8 +6595,8 @@ func TestReadThreads(t *testing.T) {
})
t.Run("1 thread by post id", func(t *testing.T) {
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store.Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.BasicUser.Id)
defer th.App.Srv().Store().Post().PermanentDeleteByUser(th.SystemAdminUser.Id)
rpost, _ := postAndCheck(t, client, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testMsgC1"})
reply1, _ := postAndCheck(t, th.SystemAdminClient, &model.Post{ChannelId: th.BasicChannel.Id, Message: "testReplyC1", RootId: rpost.Id})