[MM-62408] Server Code Coverage with Fully Parallel Tests (#30078)
* TestPool * Store infra * Store tests updates * Bump maximum concurrent postgres connections * More infra * channels/jobs * channels/app * channels/api4 * Protect i18n from concurrent access * Replace some use of os.Setenv * Remove debug * Lint fixes * Fix more linting * Fix test * Remove use of Setenv in drafts tests * Fix flaky TestWebHubCloseConnOnDBFail * Fix merge * [MM-62408] Add CI job to generate test coverage (#30284) * Add CI job to generate test coverage * Remove use of Setenv in drafts tests * Fix flaky TestWebHubCloseConnOnDBFail * Fix more Setenv usage * Fix more potential flakyness * Remove parallelism from flaky test * Remove conflicting env var * Fix * Disable parallelism * Test atomic covermode * Disable parallelism * Enable parallelism * Add upload coverage step * Fix codecov.yml * Add codecov.yml * Remove redundant workspace field * Add Parallel() util methods and refactor * Fix formatting * More formatting fixes * Fix reporting
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1cf2f08108
Коммит
611b2a8e79
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetLatestVersion(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestUnitUpdateConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -290,6 +291,7 @@ func TestDoEmojisPermissionsMigration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDBHealthCheckWriteAndDelete(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParseAuthTokenFromRequest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
cases := []struct {
|
||||
header string
|
||||
cookie string
|
||||
@@ -63,6 +64,7 @@ func TestParseAuthTokenFromRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCheckPasswordAndAllCriteria(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ func TestSessionHasPermissionToAndNotRestrictedAdmin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCheckIfRolesGrantPermission(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -144,12 +145,14 @@ func TestCheckIfRolesGrantPermission(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChannelRolesGrantPermission(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testPermissionInheritance(t, func(t *testing.T, th *TestHelper, testData permissionInheritanceTestData) {
|
||||
require.Equal(t, testData.shouldHavePermission, th.App.RolesGrantPermission([]string{testData.channelRole.Name}, testData.permission.Id), "row: %+v\n", testData.truthTableRow)
|
||||
})
|
||||
}
|
||||
|
||||
func TestHasPermissionToTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -167,6 +170,7 @@ func TestHasPermissionToTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToTeams(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -225,6 +229,7 @@ func TestSessionHasPermissionToTeams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -296,6 +301,7 @@ func TestSessionHasPermissionToChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToChannels(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -444,6 +450,7 @@ func TestSessionHasPermissionToChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPermissionToUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -453,6 +460,7 @@ func TestHasPermissionToUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToManageBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -564,6 +572,7 @@ func TestSessionHasPermissionToManageBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -614,6 +623,7 @@ func TestSessionHasPermissionToUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToManageUserOrBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -669,6 +679,7 @@ func TestSessionHasPermissionToManageUserOrBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPermissionToCategory(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
session, err := th.App.CreateSession(th.Context, &model.Session{UserId: th.BasicUser.Id, Props: model.StringMap{}})
|
||||
@@ -687,6 +698,7 @@ func TestHasPermissionToCategory(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -771,6 +783,7 @@ func TestSessionHasPermissionToGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPermissionToReadChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -885,6 +898,7 @@ func TestHasPermissionToReadChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToChannelByPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -948,6 +962,7 @@ func TestSessionHasPermissionToChannelByPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPermissionToChannelByPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSetAutoResponderStatus(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -55,6 +56,7 @@ func TestSetAutoResponderStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDisableAutoResponder(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -90,6 +92,7 @@ func TestDisableAutoResponder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendAutoResponseIfNecessary(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should send auto response when enabled", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -110,7 +113,8 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
|
||||
savedPost, _ := th.App.CreatePost(th.Context, &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: NewTestId(),
|
||||
UserId: th.BasicUser.Id},
|
||||
UserId: th.BasicUser.Id,
|
||||
},
|
||||
th.BasicChannel,
|
||||
model.CreatePostFlags{SetOnline: true})
|
||||
|
||||
@@ -140,7 +144,8 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
|
||||
savedPost, _ := th.App.CreatePost(th.Context, &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: NewTestId(),
|
||||
UserId: th.BasicUser.Id},
|
||||
UserId: th.BasicUser.Id,
|
||||
},
|
||||
th.BasicChannel,
|
||||
model.CreatePostFlags{SetOnline: true})
|
||||
|
||||
@@ -157,7 +162,8 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
|
||||
savedPost, _ := th.App.CreatePost(th.Context, &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: NewTestId(),
|
||||
UserId: th.BasicUser.Id},
|
||||
UserId: th.BasicUser.Id,
|
||||
},
|
||||
th.BasicChannel,
|
||||
model.CreatePostFlags{SetOnline: true})
|
||||
|
||||
@@ -197,7 +203,8 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
|
||||
savedPost, _ := th.App.CreatePost(th.Context, &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: NewTestId(),
|
||||
UserId: botUser.Id},
|
||||
UserId: botUser.Id,
|
||||
},
|
||||
th.BasicChannel,
|
||||
model.CreatePostFlags{SetOnline: true})
|
||||
|
||||
@@ -249,6 +256,7 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendAutoResponseSuccess(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -269,7 +277,8 @@ func TestSendAutoResponseSuccess(t *testing.T) {
|
||||
savedPost, _ := th.App.CreatePost(th.Context, &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "zz" + model.NewId() + "a",
|
||||
UserId: th.BasicUser.Id},
|
||||
UserId: th.BasicUser.Id,
|
||||
},
|
||||
th.BasicChannel,
|
||||
model.CreatePostFlags{SetOnline: true})
|
||||
|
||||
@@ -292,6 +301,7 @@ func TestSendAutoResponseSuccess(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendAutoResponseSuccessOnThread(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -312,7 +322,8 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
|
||||
parentPost, _ := th.App.CreatePost(th.Context, &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "zz" + model.NewId() + "a",
|
||||
UserId: th.BasicUser.Id},
|
||||
UserId: th.BasicUser.Id,
|
||||
},
|
||||
th.BasicChannel,
|
||||
model.CreatePostFlags{SetOnline: true})
|
||||
|
||||
@@ -344,6 +355,7 @@ func TestSendAutoResponseSuccessOnThread(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendAutoResponseFailure(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -364,7 +376,8 @@ func TestSendAutoResponseFailure(t *testing.T) {
|
||||
savedPost, _ := th.App.CreatePost(th.Context, &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "zz" + model.NewId() + "a",
|
||||
UserId: th.BasicUser.Id},
|
||||
UserId: th.BasicUser.Id,
|
||||
},
|
||||
th.BasicChannel,
|
||||
model.CreatePostFlags{SetOnline: true})
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("invalid bot", func(t *testing.T) {
|
||||
t.Run("relative to user", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
@@ -116,6 +117,7 @@ func TestCreateBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnsureBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("ensure bot should pass if already exist bot user", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -190,6 +192,7 @@ func TestEnsureBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("invalid patch for user", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -306,6 +309,7 @@ func TestPatchBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -376,6 +380,7 @@ func TestGetBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetBots(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).DeleteBots()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -586,6 +591,7 @@ func TestGetBots(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateBotActive(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("unknown bot", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -631,6 +637,7 @@ func TestUpdateBotActive(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPermanentDeleteBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -649,6 +656,7 @@ func TestPermanentDeleteBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDisableUserBots(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -710,6 +718,7 @@ func TestDisableUserBots(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -727,7 +736,8 @@ func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
|
||||
Nickname: "nn_sysadmin1",
|
||||
Password: "hello1",
|
||||
Username: "un_sysadmin1",
|
||||
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId}
|
||||
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId,
|
||||
}
|
||||
_, err := th.App.CreateUser(th.Context, &sysadmin1)
|
||||
require.Nil(t, err, "failed to create user")
|
||||
_, err = th.App.UpdateUserRoles(th.Context, sysadmin1.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false)
|
||||
@@ -738,7 +748,8 @@ func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
|
||||
Nickname: "nn_sysadmin2",
|
||||
Password: "hello1",
|
||||
Username: "un_sysadmin2",
|
||||
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId}
|
||||
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId,
|
||||
}
|
||||
_, err = th.App.CreateUser(th.Context, &sysadmin2)
|
||||
require.Nil(t, err, "failed to create user")
|
||||
_, err = th.App.UpdateUserRoles(th.Context, sysadmin2.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false)
|
||||
@@ -846,6 +857,7 @@ func TestNotifySysadminsBotOwnerDisabled(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConvertUserToBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("invalid user", func(t *testing.T) {
|
||||
t.Run("invalid user id", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
@@ -952,6 +964,7 @@ func TestConvertUserToBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSystemBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("An error should be returned if there are no sysadmins in the instance", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -16,6 +16,8 @@ import (
|
||||
)
|
||||
|
||||
func TestBusySet(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
cluster := &ClusterMock{Busy: &Busy{}, t: t}
|
||||
busy := NewBusy(cluster)
|
||||
|
||||
@@ -54,6 +56,7 @@ func TestBusySet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBusyExpires(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
cluster := &ClusterMock{Busy: &Busy{}, t: t}
|
||||
busy := NewBusy(cluster)
|
||||
|
||||
@@ -90,6 +93,7 @@ func TestBusyExpires(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBusyRace(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
cluster := &ClusterMock{Busy: &Busy{}, t: t}
|
||||
busy := NewBusy(cluster)
|
||||
|
||||
@@ -148,12 +152,15 @@ func (c *ClusterMock) NotifyMsg(buf []byte) {}
|
||||
func (c *ClusterMock) GetClusterStats(rctx request.CTX) ([]*model.ClusterStats, *model.AppError) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) GetLogs(rctx request.CTX, page, perPage int) ([]string, *model.AppError) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) QueryLogs(rctx request.CTX, page, perPage int) (map[string][]string, *model.AppError) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) GenerateSupportPacket(rctx request.CTX, options *model.SupportPacketOptions) (map[string][]model.FileData, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -165,6 +172,7 @@ func (c *ClusterMock) HealthScore() int { return 0 }
|
||||
func (c *ClusterMock) WebConnCountForUser(userID string) (int, *model.AppError) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) GetWSQueues(userID, connectionID string, seqNum int64) (map[string]*model.WSQueues, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ func createBookmark(name string, bookmarkType model.ChannelBookmarkType, channel
|
||||
}
|
||||
|
||||
func TestCreateBookmark(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -81,12 +82,13 @@ func TestCreateBookmark(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateBookmark(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
var updateBookmark *model.ChannelBookmarkWithFileInfo
|
||||
|
||||
var testUpdateAnotherFile = func(th *TestHelper, t *testing.T) {
|
||||
testUpdateAnotherFile := func(th *TestHelper, t *testing.T) {
|
||||
file := &model.FileInfo{
|
||||
Id: model.NewId(),
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
@@ -328,6 +330,7 @@ func TestUpdateBookmark(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteBookmark(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -353,6 +356,7 @@ func TestDeleteBookmark(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetChannelBookmarks(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -437,6 +441,7 @@ func TestGetChannelBookmarks(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSidebarCategory(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -86,6 +87,7 @@ func TestSidebarCategory(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSidebarCategories(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should return the sidebar categories for the given user/team", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -128,11 +130,10 @@ func TestGetSidebarCategories(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
// Temporarily renaming a table to force a DB error.
|
||||
sqlStore := mainHelper.GetSQLStore()
|
||||
_, err := sqlStore.GetMaster().Exec("ALTER TABLE SidebarCategories RENAME TO SidebarCategoriesTest")
|
||||
_, err := th.SQLStore.GetMaster().Exec("ALTER TABLE SidebarCategories RENAME TO SidebarCategoriesTest")
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
_, err := sqlStore.GetMaster().Exec("ALTER TABLE SidebarCategoriesTest RENAME TO SidebarCategories")
|
||||
_, err := th.SQLStore.GetMaster().Exec("ALTER TABLE SidebarCategoriesTest RENAME TO SidebarCategories")
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
@@ -144,6 +145,7 @@ func TestGetSidebarCategories(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateSidebarCategories(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should mute and unmute all channels in a category when it is muted or unmuted", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -487,6 +489,7 @@ func TestUpdateSidebarCategories(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDiffChannelsBetweenCategories(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should return nothing when the categories contain identical channels", func(t *testing.T) {
|
||||
originalCategories := []*model.SidebarCategoryWithChannels{
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPermanentDeleteChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -86,6 +87,7 @@ func TestPermanentDeleteChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveAllDeactivatedMembersFromChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
var appErr *model.AppError
|
||||
@@ -122,6 +124,7 @@ func TestRemoveAllDeactivatedMembersFromChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMoveChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should move channels between teams", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -304,6 +307,7 @@ func TestMoveChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveUsersFromChannelNotMemberOfTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -345,6 +349,7 @@ func TestRemoveUsersFromChannelNotMemberOfTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -377,6 +382,7 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testi
|
||||
}
|
||||
|
||||
func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordOffTopic(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -409,6 +415,7 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordOffTopic(t *testing
|
||||
}
|
||||
|
||||
func TestJoinDefaultChannelsExperimentalDefaultChannels(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -435,6 +442,7 @@ func TestJoinDefaultChannelsExperimentalDefaultChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJoinDefaultChannelsExperimentalDefaultChannelsMissing(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -465,6 +473,7 @@ func TestJoinDefaultChannelsExperimentalDefaultChannelsMissing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateChannelPublicCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -480,6 +489,7 @@ func TestCreateChannelPublicCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateChannelPrivateCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -493,7 +503,9 @@ func TestCreateChannelPrivateCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
assert.Equal(t, th.BasicUser.Id, histories[0].UserId)
|
||||
assert.Equal(t, privateChannel.Id, histories[0].ChannelId)
|
||||
}
|
||||
|
||||
func TestCreateChannelDisplayNameTrimsWhitespace(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -507,6 +519,7 @@ func TestCreateChannelDisplayNameTrimsWhitespace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateChannelPrivacy(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -520,6 +533,7 @@ func TestUpdateChannelPrivacy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetOrCreateDirectChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -574,6 +588,7 @@ func TestGetOrCreateDirectChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateGroupChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -597,6 +612,7 @@ func TestCreateGroupChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateGroupChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -627,6 +643,7 @@ func TestCreateGroupChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -653,6 +670,7 @@ func TestCreateDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -681,6 +699,7 @@ func TestGetDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddUserToChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic().DeleteBots()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -711,6 +730,7 @@ func TestAddUserToChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUsersAndPostsCreateActivityInChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic().DeleteBots()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -793,6 +813,7 @@ func TestUsersAndPostsCreateActivityInChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLeaveDefaultChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -852,6 +873,7 @@ func TestLeaveDefaultChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLeaveChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -911,6 +933,7 @@ func TestLeaveChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLeaveLastChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -940,6 +963,7 @@ func TestLeaveLastChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddChannelMemberNoUserRequestor(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -981,6 +1005,7 @@ func TestAddChannelMemberNoUserRequestor(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddChannelMemberDeletedUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -997,6 +1022,7 @@ func TestAddChannelMemberDeletedUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAppUpdateChannelScheme(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1013,6 +1039,7 @@ func TestAppUpdateChannelScheme(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetChannelsMuted(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should mute and unmute the given channels", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -1064,6 +1091,7 @@ func TestSetChannelsMuted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFillInChannelProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1284,6 +1312,7 @@ func TestFillInChannelProps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRenameChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1351,6 +1380,7 @@ func TestRenameChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetChannelMembersTimezones(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1394,6 +1424,7 @@ func TestGetChannelMembersTimezones(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetChannelsForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
channel := &model.Channel{
|
||||
DisplayName: "Public",
|
||||
@@ -1438,6 +1469,7 @@ func TestGetChannelsForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPublicChannelsForTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
team := th.CreateTeam()
|
||||
defer th.TearDown()
|
||||
@@ -1485,6 +1517,7 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPrivateChannelsForTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
team := th.CreateTeam()
|
||||
defer th.TearDown()
|
||||
@@ -1521,6 +1554,7 @@ func TestGetPrivateChannelsForTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1599,6 +1633,7 @@ func TestUpdateChannelMemberRolesChangingGuest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDefaultChannelNames(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1616,6 +1651,7 @@ func TestDefaultChannelNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchChannelsForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1673,6 +1709,7 @@ func TestSearchChannelsForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMarkChannelAsUnreadFromPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1829,6 +1866,7 @@ func TestMarkChannelAsUnreadFromPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddUserToChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1923,6 +1961,7 @@ func TestAddUserToChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveUserFromChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1982,6 +2021,7 @@ func TestRemoveUserFromChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2461,6 +2501,7 @@ func TestPatchChannelModerationsForChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClearChannelMembersCache(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2476,7 +2517,8 @@ func TestClearChannelMembersCache(t *testing.T) {
|
||||
mockChannelStore.On("GetMembers", "channelID", 100, 100).Return(model.ChannelMembers{
|
||||
model.ChannelMember{
|
||||
ChannelId: "1",
|
||||
}}, nil)
|
||||
},
|
||||
}, nil)
|
||||
mockStore.On("Channel").Return(&mockChannelStore)
|
||||
mockStore.On("GetDBSchemaVersion").Return(1, nil)
|
||||
|
||||
@@ -2484,6 +2526,7 @@ func TestClearChannelMembersCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetMemberCountsByGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2506,6 +2549,7 @@ func TestGetMemberCountsByGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetChannelsMemberCount(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2524,6 +2568,7 @@ func TestGetChannelsMemberCount(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestViewChannelCollapsedThreadsTurnedOff(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2602,6 +2647,7 @@ func TestViewChannelCollapsedThreadsTurnedOff(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMarkChannelAsUnreadFromPostCollapsedThreadsTurnedOff(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// Enable CRT
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
@@ -2689,6 +2735,7 @@ func TestMarkChannelAsUnreadFromPostCollapsedThreadsTurnedOff(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMarkUnreadCRTOffUpdatesThreads(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -2729,6 +2776,7 @@ func TestMarkUnreadCRTOffUpdatesThreads(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsCRTEnabledForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
type preference struct {
|
||||
val string
|
||||
err error
|
||||
@@ -2808,6 +2856,7 @@ func TestIsCRTEnabledForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupMessageMembersCommonTeams(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2874,6 +2923,7 @@ func TestGetGroupMessageMembersCommonTeams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConvertGroupMessageToChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3022,6 +3072,7 @@ func TestConvertGroupMessageToChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchChannelMembersNotifyProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParseStaticListArgument(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
items := []model.AutocompleteListItem{
|
||||
{
|
||||
Hint: "[hint]",
|
||||
@@ -25,12 +26,12 @@ func TestParseStaticListArgument(t *testing.T) {
|
||||
fixedArgs := &model.AutocompleteStaticListArg{PossibleArguments: items}
|
||||
|
||||
argument := &model.AutocompleteArg{
|
||||
Name: "", //positional
|
||||
Name: "", // positional
|
||||
HelpText: "some_help",
|
||||
Type: model.AutocompleteArgTypeStaticList,
|
||||
Data: fixedArgs,
|
||||
}
|
||||
found, _, _, suggestions := parseStaticListArgument(argument, "", "") //TODO understand this!
|
||||
found, _, _, suggestions := parseStaticListArgument(argument, "", "") // TODO understand this!
|
||||
assert.True(t, found)
|
||||
assert.Equal(t, []model.AutocompleteSuggestion{{Complete: "on", Suggestion: "on", Hint: "[hint]", Description: "help"}}, suggestions)
|
||||
|
||||
@@ -91,8 +92,9 @@ func TestParseStaticListArgument(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseInputTextArgument(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
argument := &model.AutocompleteArg{
|
||||
Name: "", //positional
|
||||
Name: "", // positional
|
||||
HelpText: "some_help",
|
||||
Type: model.AutocompleteArgTypeText,
|
||||
Data: &model.AutocompleteTextArg{Hint: "hint", Pattern: "pat"},
|
||||
@@ -136,8 +138,9 @@ func TestParseInputTextArgument(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseNamedArguments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
argument := &model.AutocompleteArg{
|
||||
Name: "name", //named
|
||||
Name: "name", // named
|
||||
HelpText: "some_help",
|
||||
Type: model.AutocompleteArgTypeText,
|
||||
Data: &model.AutocompleteTextArg{Hint: "hint", Pattern: "pat"},
|
||||
@@ -201,6 +204,7 @@ func TestParseNamedArguments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSuggestions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -327,6 +331,7 @@ func TestSuggestions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCommandWithOptionalArgs(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -614,6 +619,7 @@ func createJiraAutocompleteData() *model.AutocompleteData {
|
||||
}
|
||||
|
||||
func TestDynamicListArgsForBuiltin(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -637,8 +643,7 @@ func TestDynamicListArgsForBuiltin(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
type testCommandProvider struct {
|
||||
}
|
||||
type testCommandProvider struct{}
|
||||
|
||||
func (p *testCommandProvider) GetTrigger() string {
|
||||
return "bogus"
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPossibleAtMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
fixture := []struct {
|
||||
message string
|
||||
expected []string
|
||||
@@ -55,6 +56,7 @@ func TestPossibleAtMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTrimUsernameSpecialChar(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
fixture := []struct {
|
||||
word string
|
||||
expectedString string
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAsymmetricSigningKey(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
assert.NotNil(t, th.App.AsymmetricSigningKey())
|
||||
@@ -25,12 +26,14 @@ func TestAsymmetricSigningKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostActionCookieSecret(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
assert.Equal(t, 32, len(th.App.PostActionCookieSecret()))
|
||||
}
|
||||
|
||||
func TestClientConfigWithComputed(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -58,6 +61,7 @@ func TestClientConfigWithComputed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnsureInstallationDate(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -16,8 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetCPAField(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -122,8 +120,7 @@ func TestGetCPAField(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListCPAFields(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -167,8 +164,7 @@ func TestListCPAFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateCPAField(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
|
||||
cpaGroupID, cErr := th.App.CpaGroupID()
|
||||
@@ -276,8 +272,7 @@ func TestCreateCPAField(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchCPAField(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -540,8 +535,7 @@ func TestPatchCPAField(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteCPAField(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -622,8 +616,7 @@ func TestDeleteCPAField(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCPAValue(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -699,9 +692,10 @@ func TestGetCPAValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListCPAValues(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
th := Setup(t).InitBasic()
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupConfig(t, func(cfg *model.Config) {
|
||||
cfg.FeatureFlags.CustomProfileAttributes = true
|
||||
}).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
cpaGroupID, cErr := th.App.CpaGroupID()
|
||||
@@ -756,8 +750,7 @@ func TestListCPAValues(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchCPAValue(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -882,9 +875,10 @@ func TestPatchCPAValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteCPAValues(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
|
||||
th := Setup(t).InitBasic()
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupConfig(t, func(cfg *model.Config) {
|
||||
cfg.FeatureFlags.CustomProfileAttributes = true
|
||||
}).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
cpaGroupID, cErr := th.App.CpaGroupID()
|
||||
|
||||
@@ -18,6 +18,7 @@ const (
|
||||
)
|
||||
|
||||
func TestGenerateAndSaveDesktopToken(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -29,6 +30,7 @@ func TestGenerateAndSaveDesktopToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateDesktopToken(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDownloadFromURL(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -16,11 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetDraft(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_GLOBALDRAFTS", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_GLOBALDRAFTS")
|
||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "true")
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -52,11 +47,6 @@ func TestGetDraft(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("get draft feature flag", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_GLOBALDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_GLOBALDRAFTS")
|
||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||
|
||||
@@ -66,6 +56,7 @@ func TestGetDraft(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpsertDraft(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -115,11 +106,6 @@ func TestUpsertDraft(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("upsert draft feature flag", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_GLOBALDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_GLOBALDRAFTS")
|
||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||
|
||||
@@ -129,6 +115,7 @@ func TestUpsertDraft(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateDraft(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -187,6 +174,7 @@ func TestCreateDraft(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateDraft(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -232,6 +220,7 @@ func TestUpdateDraft(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetDraftsForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -346,11 +335,6 @@ func TestGetDraftsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("get drafts feature flag", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_GLOBALDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_GLOBALDRAFTS")
|
||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||
|
||||
@@ -360,6 +344,7 @@ func TestGetDraftsForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteDraft(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -388,11 +373,6 @@ func TestDeleteDraft(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("delete drafts feature flag", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_GLOBALDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_GLOBALDRAFTS")
|
||||
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
|
||||
defer th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = true })
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import (
|
||||
)
|
||||
|
||||
func TestHandleNewNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -75,6 +77,7 @@ func TestHandleNewNotifications(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCheckPendingNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -194,6 +197,7 @@ func TestCheckPendingNotifications(t *testing.T) {
|
||||
* Ensures that email batch interval defaults to 15 minutes for users that haven't explicitly set this preference
|
||||
*/
|
||||
func TestCheckPendingNotificationsDefaultInterval(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -237,6 +241,7 @@ func TestCheckPendingNotificationsDefaultInterval(t *testing.T) {
|
||||
* Ensures that email batch interval defaults to 15 minutes if user preference is invalid
|
||||
*/
|
||||
func TestCheckPendingNotificationsCantParseInterval(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package email
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -14,6 +13,8 @@ import (
|
||||
)
|
||||
|
||||
func TestCondenseSiteURL(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
require.Equal(t, "", condenseSiteURL(""))
|
||||
require.Equal(t, "mattermost.com", condenseSiteURL("mattermost.com"))
|
||||
require.Equal(t, "mattermost.com", condenseSiteURL("mattermost.com/"))
|
||||
@@ -35,6 +36,7 @@ func TestCondenseSiteURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendInviteEmails(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.ConfigureInbucketMail()
|
||||
@@ -84,13 +86,14 @@ func TestSendInviteEmails(t *testing.T) {
|
||||
|
||||
t.Run("SendInviteEmails can return error when SMTP connection fails", func(t *testing.T) {
|
||||
originalPort := *th.service.config().EmailSettings.SMTPPort
|
||||
originalTimeout := *th.service.config().EmailSettings.SMTPServerTimeout
|
||||
th.UpdateConfig(func(cfg *model.Config) {
|
||||
os.Setenv("MM_EMAILSETTINGS_SMTPPORT", "5432")
|
||||
*cfg.EmailSettings.SMTPPort = "5432"
|
||||
*cfg.EmailSettings.SMTPServerTimeout = 4
|
||||
})
|
||||
defer th.UpdateConfig(func(cfg *model.Config) {
|
||||
os.Setenv("MM_EMAILSETTINGS_SMTPPORT", originalPort)
|
||||
*cfg.EmailSettings.SMTPPort = originalPort
|
||||
*cfg.EmailSettings.SMTPServerTimeout = originalTimeout
|
||||
})
|
||||
|
||||
err := th.service.SendInviteEmails(th.BasicTeam, "test-user", th.BasicUser.Id, []string{emailTo}, "http://testserver", nil, true, false, false)
|
||||
@@ -123,14 +126,15 @@ func TestSendInviteEmails(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("SendGuestInviteEmail can return error when SMTP connection fails", func(t *testing.T) {
|
||||
originalTimeout := *th.service.config().EmailSettings.SMTPServerTimeout
|
||||
originalPort := *th.service.config().EmailSettings.SMTPPort
|
||||
th.UpdateConfig(func(cfg *model.Config) {
|
||||
os.Setenv("MM_EMAILSETTINGS_SMTPPORT", "5432")
|
||||
*cfg.EmailSettings.SMTPPort = "5432"
|
||||
*cfg.EmailSettings.SMTPServerTimeout = 4
|
||||
})
|
||||
defer th.UpdateConfig(func(cfg *model.Config) {
|
||||
os.Setenv("MM_EMAILSETTINGS_SMTPPORT", originalPort)
|
||||
*cfg.EmailSettings.SMTPPort = originalPort
|
||||
*cfg.EmailSettings.SMTPServerTimeout = originalTimeout
|
||||
})
|
||||
|
||||
err := th.service.SendGuestInviteEmails(
|
||||
@@ -255,6 +259,7 @@ func TestSendInviteEmails(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendCloudWelcomeEmail(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.ConfigureInbucketMail()
|
||||
@@ -294,6 +299,7 @@ func TestSendCloudWelcomeEmail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMailServiceConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
configuredReplyTo := "feedbackexample@test.com"
|
||||
customReplyTo := "customreplyto@test.com"
|
||||
|
||||
|
||||
@@ -41,10 +41,19 @@ func Setup(tb testing.TB) *TestHelper {
|
||||
if testing.Short() {
|
||||
tb.SkipNow()
|
||||
}
|
||||
dbStore := mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
|
||||
var dbStore store.Store
|
||||
if mainHelper.Options.RunParallel {
|
||||
dbStore, _, _, _ = mainHelper.GetNewStores(tb)
|
||||
tb.Cleanup(func() {
|
||||
dbStore.Close()
|
||||
})
|
||||
} else {
|
||||
dbStore = mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
}
|
||||
|
||||
return setupTestHelper(dbStore, tb)
|
||||
}
|
||||
|
||||
@@ -5,13 +5,18 @@ package email
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
||||
)
|
||||
|
||||
var mainHelper *testlib.MainHelper
|
||||
var replicaFlag bool
|
||||
var (
|
||||
mainHelper *testlib.MainHelper
|
||||
replicaFlag bool
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
if f := flag.Lookup("mysql-replica"); f == nil {
|
||||
@@ -19,10 +24,21 @@ func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
var options = testlib.HelperOptions{
|
||||
var parallelism int
|
||||
if f := flag.Lookup("test.parallel"); f != nil {
|
||||
parallelism, _ = strconv.Atoi(f.Value.String())
|
||||
}
|
||||
runParallel := os.Getenv("ENABLE_FULLY_PARALLEL_TESTS") == "true" && parallelism > 1
|
||||
if runParallel {
|
||||
mlog.Info("Fully parallel tests enabled", mlog.Int("parallelism", parallelism))
|
||||
}
|
||||
|
||||
options := testlib.HelperOptions{
|
||||
EnableStore: true,
|
||||
EnableResources: true,
|
||||
WithReadReplica: replicaFlag,
|
||||
RunParallel: runParallel,
|
||||
Parallelism: parallelism,
|
||||
}
|
||||
|
||||
mainHelper = testlib.NewMainHelperWithOptions(&options)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProcessMessageAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSendInviteEmailRateLimits(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetMultipleEmojiByName(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// The fact that we use mock store ensures that
|
||||
// the call to the DB does not happen. If it did, we would have needed
|
||||
// to provide the mock explicitly.
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSAMLSettings(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
tt := []struct {
|
||||
name string
|
||||
setInterface bool
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNotifySessionsExpired(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
)
|
||||
|
||||
func TestReactionsOfPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -58,6 +59,7 @@ func TestReactionsOfPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportUserNotifyProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -85,6 +87,7 @@ func TestExportUserNotifyProps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportUserChannels(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -136,6 +139,7 @@ func TestExportUserChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyEmojiImages(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -172,6 +176,7 @@ func TestCopyEmojiImages(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportCustomEmoji(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -192,6 +197,7 @@ func TestExportCustomEmoji(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportAllUsers(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t)
|
||||
defer th1.TearDown()
|
||||
|
||||
@@ -204,8 +210,15 @@ func TestExportAllUsers(t *testing.T) {
|
||||
err = th1.App.BulkExport(th1.Context, &b, "somePath", nil, model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
var th2 *TestHelper
|
||||
if mainHelper.Options.RunParallel {
|
||||
th1.Store.DropAllTables()
|
||||
th2 = th1
|
||||
} else {
|
||||
th2 = Setup(t)
|
||||
defer th2.TearDown()
|
||||
}
|
||||
|
||||
i, err := th2.App.BulkImport(th2.Context, &b, nil, false, 5)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, 0, i)
|
||||
@@ -241,6 +254,7 @@ func TestExportAllUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportAllBots(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t)
|
||||
defer th1.TearDown()
|
||||
|
||||
@@ -276,6 +290,7 @@ func TestExportAllBots(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportDMChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Export a DM channel to another server", func(t *testing.T) {
|
||||
th1 := Setup(t).InitBasic()
|
||||
defer th1.TearDown()
|
||||
@@ -406,6 +421,7 @@ func TestExportDMChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportDMChannelToSelf(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
defer th1.TearDown()
|
||||
|
||||
@@ -440,6 +456,7 @@ func TestExportDMChannelToSelf(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportGMChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
user1 := th1.CreateUser()
|
||||
@@ -469,6 +486,7 @@ func TestExportGMChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportGMandDMChannels(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
// DM Channel
|
||||
@@ -516,6 +534,7 @@ func TestExportGMandDMChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportDMandGMPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
// DM Channel
|
||||
@@ -600,6 +619,7 @@ func TestExportDMandGMPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportPostWithProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
attachments := []*model.SlackAttachment{{Footer: "footer"}}
|
||||
@@ -677,6 +697,7 @@ func TestExportPostWithProps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportUserCustomStatus(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
cs := &model.CustomStatus{
|
||||
@@ -711,6 +732,7 @@ func TestExportUserCustomStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportDMPostWithSelf(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
|
||||
// DM Channel with self (me channel)
|
||||
@@ -748,6 +770,7 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportPostsWithThread(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
defer th1.TearDown()
|
||||
|
||||
@@ -985,6 +1008,7 @@ func TestExportFileWarnings(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBulkExport(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
testsDir, _ := fileutils.FindDir("tests")
|
||||
|
||||
@@ -1039,6 +1063,7 @@ func TestBulkExport(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildPostReplies(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1103,6 +1128,7 @@ func TestBuildPostReplies(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportDeletedTeams(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
defer th1.TearDown()
|
||||
|
||||
@@ -1118,8 +1144,15 @@ func TestExportDeletedTeams(t *testing.T) {
|
||||
err = th1.App.BulkExport(th1.Context, &b, "somePath", nil, model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
var th2 *TestHelper
|
||||
if mainHelper.Options.RunParallel {
|
||||
th1.Store.DropAllTables()
|
||||
th2 = th1
|
||||
} else {
|
||||
th2 = Setup(t)
|
||||
defer th2.TearDown()
|
||||
}
|
||||
|
||||
i, err := th2.App.BulkImport(th2.Context, &b, nil, false, 5)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, i)
|
||||
@@ -1144,6 +1177,7 @@ func TestExportDeletedTeams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportArchivedChannels(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th1 := Setup(t).InitBasic()
|
||||
defer th1.TearDown()
|
||||
|
||||
@@ -1179,6 +1213,7 @@ func TestExportArchivedChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportRoles(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("defaults", func(t *testing.T) {
|
||||
th1 := Setup(t).InitBasic()
|
||||
defer th1.TearDown()
|
||||
@@ -1277,6 +1312,7 @@ func TestExportRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportSchemes(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("no schemes", func(t *testing.T) {
|
||||
th1 := Setup(t).InitBasic()
|
||||
defer th1.TearDown()
|
||||
|
||||
@@ -35,6 +35,7 @@ func assertDirectoryContents(t *testing.T, dir string, expectedFiles []string) {
|
||||
}
|
||||
|
||||
func TestExtractTarGz(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
makeArchive := func(t *testing.T, files []*tar.Header) bytes.Buffer {
|
||||
// Build an in-memory archive with the specified files, writing the path as each
|
||||
// file's contents when applicable.
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestFilterInaccessibleFiles(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
err := th.App.Srv().Store().System().Save(&model.System{
|
||||
@@ -23,7 +24,7 @@ func TestFilterInaccessibleFiles(t *testing.T) {
|
||||
|
||||
defer th.TearDown()
|
||||
|
||||
var getFileWithCreateAt = func(at int64) *model.FileInfo {
|
||||
getFileWithCreateAt := func(at int64) *model.FileInfo {
|
||||
return &model.FileInfo{CreateAt: at}
|
||||
}
|
||||
|
||||
@@ -116,6 +117,7 @@ func TestFilterInaccessibleFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetFilteredAccessibleFiles(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
err := th.App.Srv().Store().System().Save(&model.System{
|
||||
@@ -126,7 +128,7 @@ func TestGetFilteredAccessibleFiles(t *testing.T) {
|
||||
|
||||
defer th.TearDown()
|
||||
|
||||
var getFileWithCreateAt = func(at int64) *model.FileInfo {
|
||||
getFileWithCreateAt := func(at int64) *model.FileInfo {
|
||||
return &model.FileInfo{CreateAt: at}
|
||||
}
|
||||
|
||||
@@ -158,6 +160,7 @@ func TestGetFilteredAccessibleFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsInaccessibleFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
err := th.App.Srv().Store().System().Save(&model.System{
|
||||
@@ -180,6 +183,7 @@ func TestIsInaccessibleFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveInaccessibleContentFromFilesSlice(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
err := th.App.Srv().Store().System().Save(&model.System{
|
||||
@@ -190,7 +194,7 @@ func TestRemoveInaccessibleContentFromFilesSlice(t *testing.T) {
|
||||
|
||||
defer th.TearDown()
|
||||
|
||||
var getFileWithCreateAt = func(at int64) *model.FileInfo {
|
||||
getFileWithCreateAt := func(at int64) *model.FileInfo {
|
||||
return &model.FileInfo{CreateAt: at}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetInfoForFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
fakeFile := make([]byte, 1000)
|
||||
|
||||
pngFile, err := os.ReadFile("tests/test.png")
|
||||
@@ -26,7 +27,7 @@ func TestGetInfoForFile(t *testing.T) {
|
||||
animatedGifFile, err := os.ReadFile("tests/testgif.gif")
|
||||
require.NoError(t, err, "Failed to load testgif.gif")
|
||||
|
||||
var ttc = []struct {
|
||||
ttc := []struct {
|
||||
testName string
|
||||
filename string
|
||||
file []byte
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGeneratePublicLinkHash(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
filename1 := model.NewId() + "/" + model.NewRandomString(16) + ".txt"
|
||||
filename2 := model.NewId() + "/" + model.NewRandomString(16) + ".txt"
|
||||
salt1 := model.NewRandomString(32)
|
||||
@@ -48,6 +49,7 @@ func TestGeneratePublicLinkHash(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoUploadFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -109,6 +111,7 @@ func TestDoUploadFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUploadFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -137,6 +140,7 @@ func TestUploadFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseOldFilenames(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -234,6 +238,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetInfoForFilename(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -245,6 +250,7 @@ func TestGetInfoForFilename(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFindTeamIdForFilename(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -259,6 +265,7 @@ func TestFindTeamIdForFilename(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMigrateFilenamesToFileInfos(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -293,6 +300,7 @@ func TestMigrateFilenamesToFileInfos(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateZipFileAndAddFiles(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -349,6 +357,7 @@ func TestCreateZipFileAndAddFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyFileInfos(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -380,6 +389,7 @@ func TestCopyFileInfos(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerateThumbnailImage(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("test generating thumbnail image", func(t *testing.T) {
|
||||
// given
|
||||
th := Setup(t)
|
||||
@@ -409,6 +419,7 @@ func createDummyImage() *image.RGBA {
|
||||
}
|
||||
|
||||
func TestSearchFilesInTeamForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
perPage := 5
|
||||
searchTerm := "searchTerm"
|
||||
|
||||
@@ -602,6 +613,7 @@ func TestSearchFilesInTeamForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExtractContentFromFileInfo(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
app := &App{}
|
||||
fi := &model.FileInfo{
|
||||
MimeType: "image/jpeg",
|
||||
@@ -612,6 +624,7 @@ func TestExtractContentFromFileInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLastAccessibleFileTime(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -645,6 +658,7 @@ func TestGetLastAccessibleFileTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestComputeLastAccessibleFileTime(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Updates the time, if cloud limit is applicable", func(t *testing.T) {
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
@@ -704,6 +718,7 @@ func TestComputeLastAccessibleFileTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetFileSearchableContent(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -732,6 +747,7 @@ func TestSetFileSearchableContent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPermanentDeleteFilesByPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -35,6 +36,7 @@ func TestGetGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupByRemoteID(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -49,6 +51,7 @@ func TestGetGroupByRemoteID(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupsByType(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
th.CreateGroup()
|
||||
@@ -65,6 +68,7 @@ func TestGetGroupsByType(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -100,6 +104,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -117,6 +122,7 @@ func TestUpdateGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -131,6 +137,7 @@ func TestDeleteGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUndeleteGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -149,6 +156,7 @@ func TestUndeleteGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateOrRestoreGroupMember(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -163,6 +171,7 @@ func TestCreateOrRestoreGroupMember(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteGroupMember(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -180,6 +189,7 @@ func TestDeleteGroupMember(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpsertGroupSyncable(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -206,6 +216,7 @@ func TestUpsertGroupSyncable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpsertGroupSyncableTeamGroupConstrained(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -234,6 +245,7 @@ func TestUpsertGroupSyncableTeamGroupConstrained(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupSyncable(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -249,6 +261,7 @@ func TestGetGroupSyncable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupSyncables(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -267,6 +280,7 @@ func TestGetGroupSyncables(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteGroupSyncable(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -286,6 +300,7 @@ func TestDeleteGroupSyncable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupsByChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -320,6 +335,7 @@ func TestGetGroupsByChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -359,6 +375,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupsByTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -386,6 +403,7 @@ func TestGetGroupsByTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroups(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
group := th.CreateGroup()
|
||||
@@ -396,6 +414,7 @@ func TestGetGroups(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserIsInAdminRoleGroup(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
group1 := th.CreateGroup()
|
||||
|
||||
@@ -29,12 +29,15 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
||||
"github.com/mattermost/mattermost/server/v8/config"
|
||||
"github.com/mattermost/mattermost/server/v8/einterfaces"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/searchengine"
|
||||
)
|
||||
|
||||
type TestHelper struct {
|
||||
App *App
|
||||
Context *request.Context
|
||||
Server *Server
|
||||
Store store.Store
|
||||
SQLStore *sqlstore.SqlStore
|
||||
BasicTeam *model.Team
|
||||
BasicUser *model.User
|
||||
BasicUser2 *model.User
|
||||
@@ -54,8 +57,9 @@ type PostOptions func(*model.Post)
|
||||
|
||||
type PostPatchOptions func(patch *model.PostPatch)
|
||||
|
||||
func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer bool,
|
||||
updateConfig func(*model.Config), options []Option, tb testing.TB) *TestHelper {
|
||||
func setupTestHelper(dbStore store.Store, sqlStore *sqlstore.SqlStore, sqlSettings *model.SqlSettings, searchEngine *searchengine.Broker, enterprise bool, includeCacheLayer bool,
|
||||
updateConfig func(*model.Config), options []Option, tb testing.TB,
|
||||
) *TestHelper {
|
||||
tempWorkspace, err := os.MkdirTemp("", "apptest")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -63,7 +67,10 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
|
||||
configStore := config.NewTestMemoryStore()
|
||||
memoryConfig := configStore.Get()
|
||||
memoryConfig.SqlSettings = *mainHelper.GetSQLSettings()
|
||||
|
||||
memoryConfig.SqlSettings = model.SafeDereference(sqlSettings)
|
||||
*memoryConfig.ServiceSettings.LicenseFileLocation = filepath.Join(tempWorkspace, "license.json")
|
||||
*memoryConfig.FileSettings.Directory = filepath.Join(tempWorkspace, "data")
|
||||
*memoryConfig.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins")
|
||||
*memoryConfig.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp")
|
||||
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
|
||||
@@ -71,6 +78,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
*memoryConfig.LogSettings.ConsoleLevel = mlog.LvlStdLog.Name
|
||||
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
|
||||
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
|
||||
*memoryConfig.LogSettings.FileLocation = filepath.Join(tempWorkspace, "logs", "mattermost.log")
|
||||
if updateConfig != nil {
|
||||
updateConfig(memoryConfig)
|
||||
}
|
||||
@@ -111,6 +119,8 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
TestLogger: testLogger,
|
||||
IncludeCacheLayer: includeCacheLayer,
|
||||
ConfigStore: configStore,
|
||||
Store: dbStore,
|
||||
SQLStore: sqlStore,
|
||||
}
|
||||
|
||||
th.App.Srv().SetLicense(getLicense(enterprise, memoryConfig))
|
||||
@@ -119,6 +129,14 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.RateLimitSettings.Enable = false })
|
||||
prevListenAddress := *th.App.Config().ServiceSettings.ListenAddress
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = "localhost:0" })
|
||||
|
||||
// Support updating feature flags without resorting to os.Setenv which
|
||||
// isn't concurrently safe.
|
||||
if updateConfig != nil {
|
||||
configStore.SetReadOnlyFF(false)
|
||||
th.App.UpdateConfig(updateConfig)
|
||||
}
|
||||
|
||||
serverErr := th.Server.Start()
|
||||
if serverErr != nil {
|
||||
panic(serverErr)
|
||||
@@ -126,7 +144,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = prevListenAddress })
|
||||
|
||||
th.App.Srv().Platform().SearchEngine = mainHelper.SearchEngine
|
||||
th.App.Srv().Platform().SearchEngine = searchEngine
|
||||
|
||||
th.App.Srv().Store().MarkSystemRanUnitTests()
|
||||
|
||||
@@ -158,40 +176,57 @@ func getLicense(enterprise bool, cfg *model.Config) *model.License {
|
||||
return nil
|
||||
}
|
||||
|
||||
func setupStores(tb testing.TB) (store.Store, *sqlstore.SqlStore, *model.SqlSettings, *searchengine.Broker) {
|
||||
var dbStore store.Store
|
||||
var sqlStore *sqlstore.SqlStore
|
||||
var dbSettings *model.SqlSettings
|
||||
var searchEngine *searchengine.Broker
|
||||
if mainHelper.Options.RunParallel {
|
||||
dbStore, sqlStore, dbSettings, searchEngine = mainHelper.GetNewStores(tb)
|
||||
tb.Cleanup(func() {
|
||||
dbStore.Close()
|
||||
})
|
||||
} else {
|
||||
dbStore = mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
searchEngine = mainHelper.GetSearchEngine()
|
||||
dbSettings = mainHelper.GetSQLSettings()
|
||||
sqlStore = mainHelper.GetSQLStore()
|
||||
}
|
||||
|
||||
return dbStore, sqlStore, dbSettings, searchEngine
|
||||
}
|
||||
|
||||
func Setup(tb testing.TB, options ...Option) *TestHelper {
|
||||
if testing.Short() {
|
||||
tb.SkipNow()
|
||||
}
|
||||
dbStore := mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
|
||||
return setupTestHelper(dbStore, false, true, nil, options, tb)
|
||||
dbStore, sqlStore, dbSettings, searchEngine := setupStores(tb)
|
||||
|
||||
return setupTestHelper(dbStore, sqlStore, dbSettings, searchEngine, false, true, nil, options, tb)
|
||||
}
|
||||
|
||||
func SetupEnterprise(tb testing.TB, options ...Option) *TestHelper {
|
||||
if testing.Short() {
|
||||
tb.SkipNow()
|
||||
}
|
||||
dbStore := mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
|
||||
return setupTestHelper(dbStore, true, true, nil, options, tb)
|
||||
dbStore, sqlStore, dbSettings, searchEngine := setupStores(tb)
|
||||
|
||||
return setupTestHelper(dbStore, sqlStore, dbSettings, searchEngine, true, true, nil, options, tb)
|
||||
}
|
||||
|
||||
func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelper {
|
||||
if testing.Short() {
|
||||
tb.SkipNow()
|
||||
}
|
||||
dbStore := mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
|
||||
return setupTestHelper(dbStore, false, true, updateConfig, nil, tb)
|
||||
dbStore, sqlStore, dbSettings, searchEngine := setupStores(tb)
|
||||
|
||||
return setupTestHelper(dbStore, sqlStore, dbSettings, searchEngine, false, true, updateConfig, nil, tb)
|
||||
}
|
||||
|
||||
func SetupWithoutPreloadMigrations(tb testing.TB) *TestHelper {
|
||||
@@ -202,12 +237,12 @@ func SetupWithoutPreloadMigrations(tb testing.TB) *TestHelper {
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
|
||||
return setupTestHelper(dbStore, false, true, nil, nil, tb)
|
||||
return setupTestHelper(dbStore, mainHelper.GetSQLStore(), mainHelper.GetSQLSettings(), mainHelper.GetSearchEngine(), false, true, nil, nil, tb)
|
||||
}
|
||||
|
||||
func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
mockStore := testlib.GetMockStoreForSetupFunctions()
|
||||
th := setupTestHelper(mockStore, false, false, nil, nil, tb)
|
||||
th := setupTestHelper(mockStore, mainHelper.GetSQLStore(), mainHelper.GetSQLSettings(), mainHelper.GetSearchEngine(), false, false, nil, nil, tb)
|
||||
statusMock := mocks.StatusStore{}
|
||||
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
|
||||
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
|
||||
@@ -228,7 +263,7 @@ func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
|
||||
func SetupEnterpriseWithStoreMock(tb testing.TB) *TestHelper {
|
||||
mockStore := testlib.GetMockStoreForSetupFunctions()
|
||||
th := setupTestHelper(mockStore, true, false, nil, nil, tb)
|
||||
th := setupTestHelper(mockStore, mainHelper.GetSQLStore(), mainHelper.GetSQLSettings(), mainHelper.GetSearchEngine(), true, false, nil, nil, tb)
|
||||
statusMock := mocks.StatusStore{}
|
||||
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
|
||||
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
|
||||
@@ -245,44 +280,56 @@ func SetupWithClusterMock(tb testing.TB, cluster einterfaces.ClusterInterface) *
|
||||
if testing.Short() {
|
||||
tb.SkipNow()
|
||||
}
|
||||
dbStore := mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
|
||||
return setupTestHelper(dbStore, true, true, nil, []Option{SetCluster(cluster)}, tb)
|
||||
dbStore, sqlStore, dbSettings, searchEngine := setupStores(tb)
|
||||
|
||||
return setupTestHelper(dbStore, sqlStore, dbSettings, searchEngine, true, true, nil, []Option{SetCluster(cluster)}, tb)
|
||||
}
|
||||
|
||||
var initBasicOnce sync.Once
|
||||
var userCache struct {
|
||||
SystemAdminUser *model.User
|
||||
BasicUser *model.User
|
||||
BasicUser2 *model.User
|
||||
}
|
||||
var (
|
||||
initBasicOnce sync.Once
|
||||
userCache struct {
|
||||
SystemAdminUser *model.User
|
||||
BasicUser *model.User
|
||||
BasicUser2 *model.User
|
||||
}
|
||||
)
|
||||
|
||||
func (th *TestHelper) InitBasic() *TestHelper {
|
||||
// create users once and cache them because password hashing is slow
|
||||
initBasicOnce.Do(func() {
|
||||
var err *model.AppError
|
||||
|
||||
th.SystemAdminUser = th.CreateUser()
|
||||
th.App.UpdateUserRoles(th.Context, th.SystemAdminUser.Id, model.SystemUserRoleId+" "+model.SystemAdminRoleId, false)
|
||||
th.SystemAdminUser, _ = th.App.GetUser(th.SystemAdminUser.Id)
|
||||
th.SystemAdminUser, err = th.App.GetUser(th.SystemAdminUser.Id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
userCache.SystemAdminUser = th.SystemAdminUser.DeepCopy()
|
||||
|
||||
th.BasicUser = th.CreateUser()
|
||||
th.BasicUser, _ = th.App.GetUser(th.BasicUser.Id)
|
||||
th.BasicUser, err = th.App.GetUser(th.BasicUser.Id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
userCache.BasicUser = th.BasicUser.DeepCopy()
|
||||
|
||||
th.BasicUser2 = th.CreateUser()
|
||||
th.BasicUser2, _ = th.App.GetUser(th.BasicUser2.Id)
|
||||
th.BasicUser2, err = th.App.GetUser(th.BasicUser2.Id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
userCache.BasicUser2 = th.BasicUser2.DeepCopy()
|
||||
})
|
||||
|
||||
// restore cached users
|
||||
th.SystemAdminUser = userCache.SystemAdminUser.DeepCopy()
|
||||
th.BasicUser = userCache.BasicUser.DeepCopy()
|
||||
th.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
||||
|
||||
users := []*model.User{th.SystemAdminUser, th.BasicUser, th.BasicUser2}
|
||||
mainHelper.GetSQLStore().User().InsertUsers(users)
|
||||
th.Store.User().InsertUsers(users)
|
||||
|
||||
th.BasicTeam = th.CreateTeam()
|
||||
|
||||
@@ -638,8 +685,8 @@ func (th *TestHelper) TearDown() {
|
||||
}
|
||||
}
|
||||
|
||||
func (*TestHelper) GetSqlStore() *sqlstore.SqlStore {
|
||||
return mainHelper.GetSQLStore()
|
||||
func (th *TestHelper) GetSqlStore() *sqlstore.SqlStore {
|
||||
return th.SQLStore
|
||||
}
|
||||
|
||||
func (th *TestHelper) ConfigureInbucketMail() {
|
||||
@@ -657,8 +704,8 @@ func (th *TestHelper) ConfigureInbucketMail() {
|
||||
})
|
||||
}
|
||||
|
||||
func (*TestHelper) ResetRoleMigration() {
|
||||
sqlStore := mainHelper.GetSQLStore()
|
||||
func (th *TestHelper) ResetRoleMigration() {
|
||||
sqlStore := th.SQLStore
|
||||
if _, err := sqlStore.GetMaster().Exec("DELETE from Roles"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -670,8 +717,8 @@ func (*TestHelper) ResetRoleMigration() {
|
||||
}
|
||||
}
|
||||
|
||||
func (*TestHelper) ResetEmojisMigration() {
|
||||
sqlStore := mainHelper.GetSQLStore()
|
||||
func (th *TestHelper) ResetEmojisMigration() {
|
||||
sqlStore := th.SQLStore
|
||||
if _, err := sqlStore.GetMaster().Exec("UPDATE Roles SET Permissions=REPLACE(Permissions, ' create_emojis', '') WHERE builtin=True"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -852,3 +899,7 @@ func decodeJSON[T any](o any, result *T) *T {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (th *TestHelper) Parallel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
)
|
||||
|
||||
func TestImportImportScheme(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -223,6 +224,7 @@ func TestImportImportScheme(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportSchemeWithoutGuestRoles(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -411,6 +413,7 @@ func TestImportImportSchemeWithoutGuestRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportRole(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -502,6 +505,7 @@ func TestImportImportRole(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -599,6 +603,7 @@ func TestImportImportTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -745,6 +750,7 @@ func TestImportImportChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1741,6 +1747,7 @@ func TestImportImportUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportUserTeams(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
team2 := th.CreateTeam()
|
||||
@@ -1963,6 +1970,7 @@ func TestImportUserTeams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportUserChannels(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
channel2 := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
@@ -2097,6 +2105,7 @@ func TestImportUserChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportUserDefaultNotifyProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2136,6 +2145,7 @@ func TestImportUserDefaultNotifyProps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3195,6 +3205,7 @@ func TestImportimportMultiplePostLines(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3802,6 +3813,7 @@ func TestImportImportPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportDirectChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
user3 := th.CreateUser()
|
||||
@@ -4173,6 +4185,7 @@ func TestImportImportDirectChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportDirectPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -5120,6 +5133,7 @@ func TestImportImportDirectPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportImportEmoji(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -5171,6 +5185,7 @@ func TestImportImportEmoji(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportAttachment(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -5193,6 +5208,7 @@ func TestImportAttachment(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportPostAndRepliesWithAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -5434,6 +5450,7 @@ func TestImportPostAndRepliesWithAttachments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportDirectPostWithAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -5561,6 +5578,7 @@ func TestImportDirectPostWithAttachments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestZippedImportPostAndRepliesWithAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -5762,6 +5780,7 @@ func TestZippedImportPostAndRepliesWithAttachments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompareFilesContent(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
ok, err := compareFilesContent(strings.NewReader(""), strings.NewReader(""), 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -67,6 +67,7 @@ func AssertChannelCount(t *testing.T, a *App, channelType model.ChannelType, exp
|
||||
}
|
||||
|
||||
func TestImportImportLine(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -115,6 +116,7 @@ func TestImportImportLine(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStopOnError(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -145,6 +147,7 @@ func TestStopOnError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportBulkImport(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -282,6 +285,7 @@ func TestImportBulkImport(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportProcessImportDataFileVersionLine(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
data := imports.LineImportData{
|
||||
Type: "version",
|
||||
Version: model.NewPointer(1),
|
||||
@@ -451,6 +455,7 @@ func TestProcessAttachmentPaths(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
c := request.TestContext(t)
|
||||
|
||||
genAttachments := func() *[]imports.AttachmentImportData {
|
||||
@@ -633,6 +638,7 @@ func BenchmarkBulkImport(b *testing.B) {
|
||||
}
|
||||
|
||||
func TestImportBulkImportWithAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGeneratePassword(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Should be the minimum length or 4, whichever is less", func(t *testing.T) {
|
||||
password1, err := generatePassword(5)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
// Test for MM-13598 where an invalid integration URL was causing a crash
|
||||
func TestPostActionInvalidURL(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -71,6 +72,7 @@ func TestPostActionInvalidURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostActionEmptyResponse(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -172,6 +174,7 @@ func TestPostActionEmptyResponse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostAction(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testCases := []struct {
|
||||
Description string
|
||||
Channel func(th *TestHelper) *model.Channel
|
||||
@@ -463,6 +466,7 @@ func TestPostAction(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostActionProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -547,6 +551,7 @@ func TestPostActionProps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSubmitInteractiveDialog(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -669,6 +674,7 @@ func TestSubmitInteractiveDialog(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostActionRelativeURL(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -882,6 +888,7 @@ func TestPostActionRelativeURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostActionRelativePluginURL(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -891,7 +898,7 @@ func TestPostActionRelativePluginURL(t *testing.T) {
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
@@ -1079,6 +1086,7 @@ func TestPostActionRelativePluginURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoPluginRequest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetJob(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -36,6 +37,7 @@ func TestGetJob(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToCreateJob(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -132,6 +134,7 @@ func TestSessionHasPermissionToCreateJob(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionHasPermissionToReadJob(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -217,6 +220,7 @@ func TestSessionHasPermissionToReadJob(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetJobByType(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -262,6 +266,7 @@ func TestGetJobByType(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetJobsByTypes(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestLoadLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -21,6 +22,7 @@ func TestLoadLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSaveLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -31,6 +33,7 @@ func TestSaveLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -39,6 +42,7 @@ func TestRemoveLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -60,6 +64,7 @@ func TestSetLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSanitizedClientLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetServerLimits(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("base case", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -14,10 +14,11 @@ import (
|
||||
)
|
||||
|
||||
func TestCheckForClientSideCert(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
var tests = []struct {
|
||||
tests := []struct {
|
||||
pem string
|
||||
subject string
|
||||
expectedEmail string
|
||||
@@ -40,6 +41,7 @@ func TestCheckForClientSideCert(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCWSLogin(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
license := model.NewTestLicense()
|
||||
|
||||
@@ -5,13 +5,18 @@ package app
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
||||
)
|
||||
|
||||
var mainHelper *testlib.MainHelper
|
||||
var replicaFlag bool
|
||||
var (
|
||||
mainHelper *testlib.MainHelper
|
||||
replicaFlag bool
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
if f := flag.Lookup("mysql-replica"); f == nil {
|
||||
@@ -19,10 +24,21 @@ func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
var options = testlib.HelperOptions{
|
||||
var parallelism int
|
||||
if f := flag.Lookup("test.parallel"); f != nil {
|
||||
parallelism, _ = strconv.Atoi(f.Value.String())
|
||||
}
|
||||
runParallel := os.Getenv("ENABLE_FULLY_PARALLEL_TESTS") == "true" && parallelism > 1
|
||||
if runParallel {
|
||||
mlog.Info("Fully parallel tests enabled", mlog.Int("parallelism", parallelism))
|
||||
}
|
||||
|
||||
options := testlib.HelperOptions{
|
||||
EnableStore: true,
|
||||
EnableResources: true,
|
||||
WithReadReplica: replicaFlag,
|
||||
RunParallel: runParallel,
|
||||
Parallelism: parallelism,
|
||||
}
|
||||
|
||||
mainHelper = testlib.NewMainHelperWithOptions(&options)
|
||||
|
||||
@@ -28,6 +28,7 @@ func mapsToMentionKeywords(userKeywords map[string][]string, groups map[string]*
|
||||
}
|
||||
|
||||
func TestMentionKeywords_AddUserProfile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should add @user", func(t *testing.T) {
|
||||
user := &model.User{
|
||||
Id: model.NewId(),
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestIsKeywordMultibyte(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
id1 := model.NewId()
|
||||
|
||||
for name, tc := range map[string]struct {
|
||||
@@ -116,6 +117,7 @@ func TestIsKeywordMultibyte(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCheckForMentionUsers(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
id1 := model.NewId()
|
||||
id2 := model.NewId()
|
||||
|
||||
@@ -213,6 +215,7 @@ func TestCheckForMentionUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCheckForMentionGroups(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
groupID1 := model.NewId()
|
||||
groupID2 := model.NewId()
|
||||
|
||||
@@ -279,6 +282,7 @@ func TestCheckForMentionGroups(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessText(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
userID1 := model.NewId()
|
||||
|
||||
groupID1 := model.NewId()
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAddMention(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should initialize Mentions and store new mentions", func(t *testing.T) {
|
||||
m := &MentionResults{}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ func configureMetrics(th *TestHelper) {
|
||||
})
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("metrics"))
|
||||
}
|
||||
|
||||
func TestMobileMetrics(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupEnterprise(t, StartMetrics)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetDirectMessageNotificationEmailSubject(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
expectedPrefix := "[http://localhost:8065] New Direct Message from @sender on"
|
||||
user := &model.User{}
|
||||
post := &model.Post{
|
||||
@@ -33,6 +34,7 @@ func TestGetDirectMessageNotificationEmailSubject(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupMessageNotificationEmailSubjectFull(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
expectedPrefix := "[http://localhost:8065] New Group Message in sender on"
|
||||
user := &model.User{}
|
||||
post := &model.Post{
|
||||
@@ -45,6 +47,7 @@ func TestGetGroupMessageNotificationEmailSubjectFull(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupMessageNotificationEmailSubjectGeneric(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
expectedPrefix := "[http://localhost:8065] New Group Message on"
|
||||
user := &model.User{}
|
||||
post := &model.Post{
|
||||
@@ -57,6 +60,7 @@ func TestGetGroupMessageNotificationEmailSubjectGeneric(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailSubject(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
expectedPrefix := "[http://localhost:8065] Notification in team on"
|
||||
user := &model.User{}
|
||||
post := &model.Post{
|
||||
@@ -68,6 +72,7 @@ func TestGetNotificationEmailSubject(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationPublicChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -99,6 +104,7 @@ func TestGetNotificationEmailBodyFullNotificationPublicChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationGroupChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -130,6 +136,7 @@ func TestGetNotificationEmailBodyFullNotificationGroupChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationPrivateChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -161,6 +168,7 @@ func TestGetNotificationEmailBodyFullNotificationPrivateChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationDirectChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -192,6 +200,7 @@ func TestGetNotificationEmailBodyFullNotificationDirectChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationLocaleTimeWithTimezone(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -227,6 +236,7 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTimeWithTimezone(t *testi
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationLocaleTimeNoTimezone(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -275,6 +285,7 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTimeNoTimezone(t *testing
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationLocaleTime12Hour(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -308,6 +319,7 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTime12Hour(t *testing.T)
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationLocaleTime24Hour(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -341,6 +353,7 @@ func TestGetNotificationEmailBodyFullNotificationLocaleTime24Hour(t *testing.T)
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyWithUserPreference(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -385,6 +398,7 @@ func TestGetNotificationEmailBodyWithUserPreference(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyFullNotificationWithSlackAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -483,6 +497,7 @@ func TestGetNotificationEmailBodyFullNotificationWithSlackAttachments(t *testing
|
||||
|
||||
// from here
|
||||
func TestGetNotificationEmailBodyGenericNotificationPublicChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -513,6 +528,7 @@ func TestGetNotificationEmailBodyGenericNotificationPublicChannel(t *testing.T)
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyGenericNotificationGroupChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -543,6 +559,7 @@ func TestGetNotificationEmailBodyGenericNotificationGroupChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyGenericNotificationPrivateChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -573,6 +590,7 @@ func TestGetNotificationEmailBodyGenericNotificationPrivateChannel(t *testing.T)
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyGenericNotificationDirectChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -603,6 +621,7 @@ func TestGetNotificationEmailBodyGenericNotificationDirectChannel(t *testing.T)
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailEscapingChars(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -637,6 +656,7 @@ func TestGetNotificationEmailEscapingChars(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyPublicChannelMention(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -684,6 +704,7 @@ func TestGetNotificationEmailBodyPublicChannelMention(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyMultiPublicChannelMention(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -756,6 +777,7 @@ func TestGetNotificationEmailBodyMultiPublicChannelMention(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationEmailBodyPrivateChannelMention(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -803,6 +825,7 @@ func TestGetNotificationEmailBodyPrivateChannelMention(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerateHyperlinkForChannelsPublic(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -834,6 +857,7 @@ func TestGenerateHyperlinkForChannelsPublic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerateHyperlinkForChannelsMultiPublic(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -890,6 +914,7 @@ func TestGenerateHyperlinkForChannelsMultiPublic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerateHyperlinkForChannelsPrivate(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -919,6 +944,7 @@ func TestGenerateHyperlinkForChannelsPrivate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLandingLink(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -948,6 +974,7 @@ func TestLandingLink(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLandingLinkPermalink(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -978,6 +1005,7 @@ func TestLandingLinkPermalink(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMarkdownConversion(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
tests := []struct {
|
||||
name string
|
||||
args string
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDoesNotifyPropsAllowPushNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
tt := []struct {
|
||||
name string
|
||||
userNotifySetting string
|
||||
@@ -431,6 +432,7 @@ func TestDoesNotifyPropsAllowPushNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoesStatusAllowPushNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -646,6 +648,7 @@ func TestDoesStatusAllowPushNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPushNotificationMessage(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1028,6 +1031,7 @@ func TestGetPushNotificationMessage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildPushNotificationMessageMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1084,6 +1088,7 @@ func TestBuildPushNotificationMessageMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendPushNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
_, err := th.App.CreateSession(th.Context, &model.Session{
|
||||
@@ -1104,6 +1109,7 @@ func TestSendPushNotifications(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShouldSendPushNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
t.Run("should return true if forced", func(t *testing.T) {
|
||||
@@ -1238,6 +1244,7 @@ func (h *testPushNotificationHandler) notificationAcks() []*model.PushNotificati
|
||||
}
|
||||
|
||||
func TestClearPushNotificationSync(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1314,6 +1321,7 @@ func TestClearPushNotificationSync(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateMobileAppBadgeSync(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1373,6 +1381,7 @@ func TestUpdateMobileAppBadgeSync(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendTestPushNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1400,6 +1409,7 @@ func TestSendTestPushNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendAckToPushProxy(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1444,6 +1454,7 @@ func TestSendAckToPushProxy(t *testing.T) {
|
||||
// TestAllPushNotifications is a master test which sends all various types
|
||||
// of notifications and verifies they have been properly sent.
|
||||
func TestAllPushNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
if testing.Short() {
|
||||
t.Skip("skipping all push notifications test in short mode")
|
||||
}
|
||||
@@ -1554,6 +1565,7 @@ func TestAllPushNotifications(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPushNotificationRace(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1610,6 +1622,7 @@ func TestPushNotificationRace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPushNotificationAttachment(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ func getLicWithSkuShortName(skuShortName string) *model.License {
|
||||
}
|
||||
|
||||
func TestSendNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -217,6 +218,7 @@ func TestSendNotifications(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendNotifications_MentionsFollowers(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -530,6 +532,7 @@ func connectFakeWebSocket(t *testing.T, th *TestHelper, userID string, connectio
|
||||
}
|
||||
|
||||
func TestConnectFakeWebSocket(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -564,6 +567,7 @@ func TestConnectFakeWebSocket(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendNotificationsWithManyUsers(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -618,6 +622,7 @@ func TestSendNotificationsWithManyUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendOutOfChannelMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -659,6 +664,7 @@ func TestSendOutOfChannelMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFilterOutOfChannelMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -852,6 +858,7 @@ func TestFilterOutOfChannelMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetExplicitMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
id1 := model.NewId()
|
||||
id2 := model.NewId()
|
||||
id3 := model.NewId()
|
||||
@@ -1440,6 +1447,7 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetExplicitMentionsAtHere(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Boundary cases", func(t *testing.T) {
|
||||
// test all the boundary cases that we know can break up terms (and those that we know won't)
|
||||
cases := map[string]bool{
|
||||
@@ -1516,6 +1524,7 @@ func TestGetExplicitMentionsAtHere(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllowChannelMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1554,6 +1563,7 @@ func TestAllowChannelMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllowGroupMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1612,6 +1622,7 @@ func TestAllowGroupMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetMentionKeywords(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1937,6 +1948,7 @@ func TestGetMentionKeywords(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetMentionKeywords_Groups(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2186,6 +2198,7 @@ func TestGetMentionKeywords_Groups(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetMentionsEnabledFields(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
attachmentWithTextAndPreText := model.SlackAttachment{
|
||||
Text: "@here with mentions",
|
||||
Pretext: "@Channel some comment for the channel",
|
||||
@@ -2225,6 +2238,7 @@ func TestGetMentionsEnabledFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostNotificationGetChannelName(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
sender := &model.User{Id: model.NewId(), Username: "sender", FirstName: "Sender", LastName: "Sender", Nickname: "Sender"}
|
||||
recipient := &model.User{Id: model.NewId(), Username: "recipient", FirstName: "Recipient", LastName: "Recipient", Nickname: "Recipient"}
|
||||
otherUser := &model.User{Id: model.NewId(), Username: "other", FirstName: "Other", LastName: "Other", Nickname: "Other"}
|
||||
@@ -2307,6 +2321,7 @@ func TestPostNotificationGetChannelName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostNotificationGetSenderName(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2411,6 +2426,7 @@ func TestPostNotificationGetSenderName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationNameFormat(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2434,6 +2450,7 @@ func TestGetNotificationNameFormat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserAllowsEmail(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2544,6 +2561,7 @@ func TestUserAllowsEmail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInsertGroupMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2678,6 +2696,7 @@ func TestInsertGroupMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2803,6 +2822,7 @@ func TestGetGroupsAllowedForReferenceInChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReplyPostNotificationsWithCRT(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Reply posts only shows badges for explicit mentions in collapsed threads", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -2959,6 +2979,7 @@ func TestReplyPostNotificationsWithCRT(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChannelAutoFollowThreads(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3022,6 +3043,7 @@ func TestChannelAutoFollowThreads(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3135,6 +3157,7 @@ func TestRemoveNotifications(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShouldAckWebsocketNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should return true if channel notify level is ALL", func(t *testing.T) {
|
||||
assert.True(t, shouldAckWebsocketNotification(model.ChannelTypeOpen, model.UserNotifyNone, model.ChannelNotifyAll))
|
||||
})
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("no error sending non trial upgrade post when no notifications are available", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -65,7 +66,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
// message sending is async, wait time for it
|
||||
var channel *model.Channel
|
||||
var err error
|
||||
var timeout = 5 * time.Second
|
||||
timeout := 5 * time.Second
|
||||
begin := time.Now()
|
||||
for {
|
||||
if time.Since(begin) > timeout {
|
||||
@@ -112,7 +113,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
// message sending is async, wait time for it
|
||||
var channel *model.Channel
|
||||
var err error
|
||||
var timeout = 5 * time.Second
|
||||
timeout := 5 * time.Second
|
||||
begin := time.Now()
|
||||
for {
|
||||
if time.Since(begin) > timeout {
|
||||
@@ -233,7 +234,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
// message sending is async, wait time for it
|
||||
var channel *model.Channel
|
||||
var err error
|
||||
var timeout = 5 * time.Second
|
||||
timeout := 5 * time.Second
|
||||
begin := time.Now()
|
||||
for {
|
||||
if time.Since(begin) > timeout {
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetOAuthAccessTokenForImplicitFlow(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -74,6 +75,7 @@ func TestGetOAuthAccessTokenForImplicitFlow(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -92,6 +94,7 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOAuthDeleteApp(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -135,7 +138,10 @@ func TestOAuthDeleteApp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
setup := func(t *testing.T, enable, tokenEndpoint, userEndpoint bool, serverURL string) *TestHelper {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := Setup(t)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -545,6 +551,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAuthorizationCode(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("not enabled", func(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
@@ -602,6 +609,7 @@ func TestGetAuthorizationCode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeauthorizeOAuthApp(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -644,6 +652,7 @@ func TestDeauthorizeOAuthApp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeactivatedUserOAuthApp(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestOnboardingSavesOrganizationName(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ func BenchmarkForceHTMLEncodingToUTF8(b *testing.B) {
|
||||
}
|
||||
|
||||
func TestMakeOpenGraphURLsAbsolute(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
for name, tc := range map[string]struct {
|
||||
HTML string
|
||||
RequestURL string
|
||||
@@ -128,6 +129,7 @@ func TestMakeOpenGraphURLsAbsolute(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOpenGraphDecodeHTMLEntities(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
og := opengraph.NewOpenGraph()
|
||||
og.Title = "Test's are the best.©"
|
||||
og.Description = "Test's are the worst.©"
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestApplyPermissionsMap(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
tt := []struct {
|
||||
Name string
|
||||
RoleMap map[string]map[string]bool
|
||||
@@ -206,6 +207,7 @@ func TestApplyPermissionsMap(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApplyPermissionsMapToSchemeRole(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
schemeRoleName := model.NewId()
|
||||
tt := []struct {
|
||||
Name string
|
||||
|
||||
@@ -23,6 +23,7 @@ func (tw testWriter) Write(p []byte) (int, error) {
|
||||
}
|
||||
|
||||
func TestExportPermissions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -90,6 +91,7 @@ func TestExportPermissions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMigration(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import (
|
||||
)
|
||||
|
||||
func TestBusySet(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
cluster := &ClusterMock{Busy: &Busy{}, t: t}
|
||||
busy := NewBusy(cluster)
|
||||
|
||||
@@ -30,9 +32,9 @@ func TestBusySet(t *testing.T) {
|
||||
require.True(t, compareBusyState(t, busy, cluster.Busy))
|
||||
|
||||
// should automatically expire after 5s.
|
||||
require.Eventually(t, isNotBusy, time.Second*15, time.Millisecond*100)
|
||||
require.Eventually(t, isNotBusy, time.Second*10, time.Millisecond*100)
|
||||
// allow a moment for cluster to sync.
|
||||
require.Eventually(t, func() bool { return compareBusyState(t, busy, cluster.Busy) }, time.Second*15, time.Millisecond*20)
|
||||
require.Eventually(t, func() bool { return compareBusyState(t, busy, cluster.Busy) }, time.Second*5, time.Millisecond*20)
|
||||
|
||||
// test set after auto expiry.
|
||||
busy.Set(time.Second * 30)
|
||||
@@ -54,6 +56,8 @@ func TestBusySet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBusyExpires(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
cluster := &ClusterMock{Busy: &Busy{}, t: t}
|
||||
busy := NewBusy(cluster)
|
||||
|
||||
@@ -86,10 +90,12 @@ func TestBusyExpires(t *testing.T) {
|
||||
// should be time.Time zero value
|
||||
require.Equal(t, time.Time{}.Unix(), expire.Unix())
|
||||
// allow a moment for cluster to sync
|
||||
require.Eventually(t, func() bool { return compareBusyState(t, busy, cluster.Busy) }, time.Second*15, time.Millisecond*20)
|
||||
require.Eventually(t, func() bool { return compareBusyState(t, busy, cluster.Busy) }, time.Second*5, time.Millisecond*20)
|
||||
}
|
||||
|
||||
func TestBusyRace(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
cluster := &ClusterMock{Busy: &Busy{}, t: t}
|
||||
busy := NewBusy(cluster)
|
||||
|
||||
@@ -147,12 +153,15 @@ func (c *ClusterMock) NotifyMsg(buf []byte) {}
|
||||
func (c *ClusterMock) GetClusterStats(rctx request.CTX) ([]*model.ClusterStats, *model.AppError) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) GetLogs(rctx request.CTX, page, perPage int) ([]string, *model.AppError) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) QueryLogs(rctx request.CTX, page, perPage int) (map[string][]string, *model.AppError) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) GenerateSupportPacket(rctx request.CTX, options *model.SupportPacketOptions) (map[string][]model.FileData, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -164,6 +173,7 @@ func (c *ClusterMock) HealthScore() int { return 0 }
|
||||
func (c *ClusterMock) WebConnCountForUser(userID string) (int, *model.AppError) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMock) GetWSQueues(userID, connectionID string, seqNum int64) (map[string]*model.WSQueues, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestClusterDiscoveryService(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestConfigListener(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -53,6 +54,7 @@ func TestConfigListener(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConfigSave(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
cm := &mocks.ClusterInterface{}
|
||||
cm.On("SendClusterMessage", mock.AnythingOfType("*model.ClusterMessage")).Return(nil)
|
||||
th := SetupWithCluster(t, cm)
|
||||
@@ -106,6 +108,7 @@ func TestConfigSave(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsFirstUserAccount(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
storeMock := th.Service.Store.(*smocks.Store)
|
||||
@@ -148,6 +151,7 @@ func TestIsFirstUserAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsFirstUserAccountThunderingHerd(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
storeMock := th.Service.Store.(*smocks.Store)
|
||||
|
||||
@@ -25,6 +25,7 @@ type TestHelper struct {
|
||||
Context request.CTX
|
||||
Service *PlatformService
|
||||
Suite SuiteIFace
|
||||
Store store.Store
|
||||
|
||||
BasicTeam *model.Team
|
||||
BasicUser *model.User
|
||||
@@ -35,15 +36,16 @@ type TestHelper struct {
|
||||
SystemAdminUser *model.User
|
||||
}
|
||||
|
||||
var initBasicOnce sync.Once
|
||||
var userCache struct {
|
||||
SystemAdminUser *model.User
|
||||
BasicUser *model.User
|
||||
BasicUser2 *model.User
|
||||
}
|
||||
var (
|
||||
initBasicOnce sync.Once
|
||||
userCache struct {
|
||||
SystemAdminUser *model.User
|
||||
BasicUser *model.User
|
||||
BasicUser2 *model.User
|
||||
}
|
||||
)
|
||||
|
||||
type mockSuite struct {
|
||||
}
|
||||
type mockSuite struct{}
|
||||
|
||||
func (ms *mockSuite) SetStatusLastActivityAt(userID string, activityAt int64) {}
|
||||
func (ms *mockSuite) SetStatusOffline(userID string, manual bool, force bool) {}
|
||||
@@ -58,20 +60,38 @@ func (ms *mockSuite) RolesGrantPermission(roleNames []string, permissionId strin
|
||||
func (ms *mockSuite) UserCanSeeOtherUser(c request.CTX, userID string, otherUserId string) (bool, *model.AppError) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (ms *mockSuite) HasPermissionToReadChannel(c request.CTX, userID string, channel *model.Channel) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func setupDBStore(tb testing.TB) (store.Store, *model.SqlSettings) {
|
||||
var dbStore store.Store
|
||||
var dbSettings *model.SqlSettings
|
||||
if mainHelper.Options.RunParallel {
|
||||
dbStore, _, dbSettings, _ = mainHelper.GetNewStores(tb)
|
||||
tb.Cleanup(func() {
|
||||
dbStore.Close()
|
||||
})
|
||||
} else {
|
||||
dbStore = mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
dbSettings = mainHelper.Settings
|
||||
mainHelper.PreloadMigrations()
|
||||
}
|
||||
|
||||
return dbStore, dbSettings
|
||||
}
|
||||
|
||||
func Setup(tb testing.TB, options ...Option) *TestHelper {
|
||||
if testing.Short() {
|
||||
tb.SkipNow()
|
||||
}
|
||||
dbStore := mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
|
||||
return setupTestHelper(dbStore, false, true, tb, options...)
|
||||
dbStore, dbSettings := setupDBStore(tb)
|
||||
|
||||
return setupTestHelper(dbStore, dbSettings, false, true, tb, options...)
|
||||
}
|
||||
|
||||
func (th *TestHelper) InitBasic() *TestHelper {
|
||||
@@ -92,7 +112,7 @@ func (th *TestHelper) InitBasic() *TestHelper {
|
||||
th.BasicUser2 = userCache.BasicUser2.DeepCopy()
|
||||
|
||||
users := []*model.User{th.SystemAdminUser, th.BasicUser, th.BasicUser2}
|
||||
mainHelper.GetSQLStore().User().InsertUsers(users)
|
||||
th.Store.User().InsertUsers(users)
|
||||
|
||||
th.BasicTeam = th.CreateTeam()
|
||||
|
||||
@@ -106,7 +126,7 @@ func (th *TestHelper) InitBasic() *TestHelper {
|
||||
func SetupWithStoreMock(tb testing.TB, options ...Option) *TestHelper {
|
||||
mockStore := testlib.GetMockStoreForSetupFunctions()
|
||||
options = append(options, StoreOverride(mockStore))
|
||||
th := setupTestHelper(mockStore, false, false, tb, options...)
|
||||
th := setupTestHelper(mockStore, &model.SqlSettings{}, false, false, tb, options...)
|
||||
return th
|
||||
}
|
||||
|
||||
@@ -114,18 +134,16 @@ func SetupWithCluster(tb testing.TB, cluster einterfaces.ClusterInterface) *Test
|
||||
if testing.Short() {
|
||||
tb.SkipNow()
|
||||
}
|
||||
dbStore := mainHelper.GetStore()
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
mainHelper.PreloadMigrations()
|
||||
|
||||
th := setupTestHelper(dbStore, true, true, tb)
|
||||
dbStore, dbSettings := setupDBStore(tb)
|
||||
|
||||
th := setupTestHelper(dbStore, dbSettings, true, true, tb)
|
||||
th.Service.clusterIFace = cluster
|
||||
|
||||
return th
|
||||
}
|
||||
|
||||
func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer bool, tb testing.TB, options ...Option) *TestHelper {
|
||||
func setupTestHelper(dbStore store.Store, dbSettings *model.SqlSettings, enterprise bool, includeCacheLayer bool, tb testing.TB, options ...Option) *TestHelper {
|
||||
tempWorkspace, err := os.MkdirTemp("", "apptest")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -134,7 +152,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
configStore := config.NewTestMemoryStore()
|
||||
|
||||
memoryConfig := configStore.Get()
|
||||
memoryConfig.SqlSettings = *mainHelper.GetSQLSettings()
|
||||
memoryConfig.SqlSettings = *dbSettings
|
||||
*memoryConfig.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins")
|
||||
*memoryConfig.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp")
|
||||
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
|
||||
@@ -161,6 +179,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
Context: request.TestContext(tb),
|
||||
Service: ps,
|
||||
Suite: &mockSuite{},
|
||||
Store: dbStore,
|
||||
}
|
||||
|
||||
if _, ok := dbStore.(*mocks.Store); ok {
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestLoadLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -26,6 +27,7 @@ func TestLoadLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSaveLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -75,6 +77,7 @@ func TestSaveEnterpriseAdvancedLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -83,6 +86,7 @@ func TestRemoveLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -104,6 +108,7 @@ func TestSetLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSanitizedClientLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ import (
|
||||
)
|
||||
|
||||
func TestGetMattermostLog(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -72,6 +74,8 @@ func TestGetMattermostLog(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetNotificationLogFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -117,6 +121,8 @@ func TestGetNotificationLogFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAdvancedLogs(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -5,13 +5,18 @@ package platform
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
||||
)
|
||||
|
||||
var mainHelper *testlib.MainHelper
|
||||
var replicaFlag bool
|
||||
var (
|
||||
mainHelper *testlib.MainHelper
|
||||
replicaFlag bool
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
if f := flag.Lookup("mysql-replica"); f == nil {
|
||||
@@ -19,10 +24,21 @@ func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
var options = testlib.HelperOptions{
|
||||
var parallelism int
|
||||
if f := flag.Lookup("test.parallel"); f != nil {
|
||||
parallelism, _ = strconv.Atoi(f.Value.String())
|
||||
}
|
||||
runParallel := os.Getenv("ENABLE_FULLY_PARALLEL_TESTS") == "true" && parallelism > 1
|
||||
if runParallel {
|
||||
mlog.Info("Fully parallel tests enabled", mlog.Int("parallelism", parallelism))
|
||||
}
|
||||
|
||||
options := testlib.HelperOptions{
|
||||
EnableStore: true,
|
||||
EnableResources: true,
|
||||
WithReadReplica: replicaFlag,
|
||||
RunParallel: runParallel,
|
||||
Parallelism: parallelism,
|
||||
}
|
||||
|
||||
mainHelper = testlib.NewMainHelperWithOptions(&options)
|
||||
|
||||
@@ -59,6 +59,7 @@ func TestSetLicenseOnStart(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadReplicaDisabledBasedOnLicense(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
cfg := model.Config{}
|
||||
cfg.SetDefaults()
|
||||
driverName := os.Getenv("MM_SQLSETTINGS_DRIVERNAME")
|
||||
@@ -131,7 +132,9 @@ func TestReadReplicaDisabledBasedOnLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMetrics(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("ensure the metrics server is not started by default", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -139,6 +142,7 @@ func TestMetrics(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ensure the metrics server is started", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t, StartMetrics())
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -166,6 +170,7 @@ func TestMetrics(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ensure the metrics server is started with advanced metrics", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t, StartMetrics())
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -180,6 +185,7 @@ func TestMetrics(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ensure advanced metrics have database metrics", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
mockMetricsImpl := &mocks.MetricsInterface{}
|
||||
mockMetricsImpl.On("Register").Return()
|
||||
mockMetricsImpl.On("ObserveStoreMethodDuration", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
@@ -198,6 +204,7 @@ func TestMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShutdown(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should shutdown gracefully", func(t *testing.T) {
|
||||
th := Setup(t)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
@@ -219,6 +226,7 @@ func TestShutdown(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetTelemetryId(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("ensure client config is regenerated after setting the telemetry id", func(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
@@ -235,6 +243,7 @@ func TestSetTelemetryId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDatabaseTypeAndMattermostVersion(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ const (
|
||||
)
|
||||
|
||||
func TestCache(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -71,6 +72,7 @@ func TestCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetSessionExpireInHours(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -117,6 +119,7 @@ func TestSetSessionExpireInHours(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -149,6 +152,7 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateSessionsIsGuest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
)
|
||||
|
||||
func TestGenerateSupportPacket(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ func (h *testBroadcastHook) Process(msg *HookedWebSocketEvent, webConn *WebConn,
|
||||
}
|
||||
|
||||
func TestRunBroadcastHooks(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
hub := &Hub{
|
||||
broadcastHooks: map[string]BroadcastHook{
|
||||
broadcastTest: &testBroadcastHook{},
|
||||
|
||||
@@ -60,6 +60,7 @@ func registerDummyWebConn(t *testing.T, th *TestHelper, addr net.Addr, session *
|
||||
}
|
||||
|
||||
func TestHubStopWithMultipleConnections(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -84,6 +85,7 @@ func TestHubStopWithMultipleConnections(t *testing.T) {
|
||||
// TestHubStopRaceCondition verifies that attempts to use the hub after it has shutdown does not
|
||||
// block the caller indefinitely.
|
||||
func TestHubStopRaceCondition(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.Service.Store.Close()
|
||||
// We do not call TearDown because th.TearDown shuts down the hub again. And hub close is not idempotent.
|
||||
@@ -131,6 +133,7 @@ func TestHubStopRaceCondition(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHubSessionRevokeRace(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -184,6 +187,7 @@ func TestHubSessionRevokeRace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHubConnIndex(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -435,6 +439,7 @@ func TestHubConnIndex(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHubConnIndexIncorrectRemoval(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -485,6 +490,7 @@ func TestHubConnIndexIncorrectRemoval(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHubConnIndexInactive(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -549,6 +555,7 @@ func TestHubConnIndexInactive(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReliableWebSocketSend(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testCluster := &testlib.FakeClusterInterface{}
|
||||
|
||||
th := SetupWithCluster(t, testCluster)
|
||||
@@ -584,6 +591,7 @@ func TestReliableWebSocketSend(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHubIsRegistered(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -620,6 +628,7 @@ func TestHubIsRegistered(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHubWebConnCount(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -841,6 +850,7 @@ func BenchmarkHubConnIndex(b *testing.B) {
|
||||
}
|
||||
|
||||
func TestHubConnIndexRemoveMemLeak(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -893,6 +903,7 @@ func BenchmarkGetHubForUserId(b *testing.B) {
|
||||
}
|
||||
|
||||
func TestClusterBroadcast(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testCluster := &testlib.FakeClusterInterface{}
|
||||
|
||||
th := SetupWithCluster(t, testCluster)
|
||||
@@ -921,6 +932,7 @@ func TestClusterBroadcast(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClusterBroadcastHooks(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should send broadcast hook information across cluster", func(t *testing.T) {
|
||||
testCluster := &testlib.FakeClusterInterface{}
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ func setupPluginAPITest(t *testing.T, pluginCode string, pluginManifest string,
|
||||
}
|
||||
|
||||
func TestPublicFilesPathConfiguration(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -164,6 +165,7 @@ func TestPublicFilesPathConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUserPreference(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should return preferences when called", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -211,6 +213,7 @@ func TestPluginAPIGetUserPreference(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUserPreferences(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -244,6 +247,7 @@ func TestPluginAPIGetUserPreferences(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIDeleteUserPreferences(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -305,6 +309,7 @@ func TestPluginAPIDeleteUserPreferences(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIUpdateUserPreferences(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -356,6 +361,7 @@ func TestPluginAPIUpdateUserPreferences(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUsers(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).DeleteBots()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -455,6 +461,7 @@ func TestPluginAPIGetUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUsersByIds(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).DeleteBots()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -519,6 +526,7 @@ func TestPluginAPIGetUsersByIds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUsersInTeam(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -647,6 +655,7 @@ func TestPluginAPIGetUsersInTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIUserCustomStatus(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -703,6 +712,7 @@ func TestPluginAPIUserCustomStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -731,6 +741,7 @@ func TestPluginAPIGetFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetFileInfos(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -828,6 +839,7 @@ func TestPluginAPIGetFileInfos(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPISavePluginConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -871,6 +883,7 @@ func TestPluginAPISavePluginConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -904,6 +917,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -941,6 +955,7 @@ func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetPlugins(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1000,6 +1015,7 @@ func TestPluginAPIGetPlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIInstallPlugin(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1036,6 +1052,7 @@ func TestPluginAPIInstallPlugin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstallPlugin(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// TODO(ilgooz): remove this setup func to use existent setupPluginAPITest().
|
||||
// following setupTest() func is a modified version of setupPluginAPITest().
|
||||
// we need a modified version of setupPluginAPITest() because it wasn't possible to use it directly here
|
||||
@@ -1162,6 +1179,7 @@ func TestInstallPlugin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetTeamIcon(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1193,6 +1211,7 @@ func TestPluginAPIGetTeamIcon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPISetTeamIcon(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1223,6 +1242,7 @@ func TestPluginAPISetTeamIcon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIRemoveTeamIcon(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1278,6 +1298,7 @@ func pluginAPIHookTest(t *testing.T, th *TestHelper, fileName string, id string,
|
||||
// 5. Successfully running test should return nil, "OK". Any other returned string is considered and error
|
||||
|
||||
func TestBasicAPIPlugins(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
defaultSchema := getDefaultPluginSettingsSchema()
|
||||
testFolder := filepath.Join(server.GetPackagePath(), "channels", "app", "plugin_api_tests")
|
||||
dirs, err := os.ReadDir(testFolder)
|
||||
@@ -1286,6 +1307,8 @@ func TestBasicAPIPlugins(t *testing.T) {
|
||||
d := dir.Name()
|
||||
if dir.IsDir() && !strings.HasPrefix(d, "manual.") {
|
||||
t.Run(d, func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
mainPath := filepath.Join(testFolder, d, "main.go")
|
||||
_, err := os.Stat(mainPath)
|
||||
require.NoError(t, err, "Cannot find plugin main file at %v", mainPath)
|
||||
@@ -1300,6 +1323,7 @@ func TestBasicAPIPlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIKVCompareAndSet(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1396,6 +1420,7 @@ func TestPluginAPIKVCompareAndSet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIKVCompareAndDelete(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1448,6 +1473,7 @@ func TestPluginAPIKVCompareAndDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginCreateBot(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1469,6 +1495,7 @@ func TestPluginCreateBot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginCreatePostWithUploadedFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1505,6 +1532,7 @@ func TestPluginCreatePostWithUploadedFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginCreatePostAddsFromPluginProp(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1524,6 +1552,7 @@ func TestPluginCreatePostAddsFromPluginProp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1561,6 +1590,7 @@ func TestPluginAPIGetConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetUnsanitizedConfig(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1598,6 +1628,7 @@ func TestPluginAPIGetUnsanitizedConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAddUserToChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -1610,6 +1641,7 @@ func TestPluginAddUserToChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInterpluginPluginHTTP(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1740,6 +1772,7 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAPIMetrics(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1821,6 +1854,7 @@ func TestAPIMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetPostsForChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
require := require.New(t)
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
@@ -1864,6 +1898,7 @@ func TestPluginAPIGetPostsForChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginHTTPConnHijack(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1983,6 +2018,7 @@ func TestPluginMFAEnforcement(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginHTTPUpgradeWebSocket(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2054,6 +2090,7 @@ func (mscp *MockSlashCommandProvider) DoCommand(a *App, c request.CTX, args *mod
|
||||
}
|
||||
|
||||
func TestPluginExecuteSlashCommand(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2079,6 +2116,7 @@ func TestPluginExecuteSlashCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPISearchPostsInTeamByUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2126,6 +2164,7 @@ func TestPluginAPISearchPostsInTeamByUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPICreateCommandAndListCommands(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2164,6 +2203,7 @@ func TestPluginAPICreateCommandAndListCommands(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIUpdateCommand(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
@@ -2222,6 +2262,7 @@ func TestPluginAPIIsEnterpriseReady(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginUploadsAPI(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2321,6 +2362,7 @@ func TestPluginUploadsAPI(t *testing.T) {
|
||||
var configurationWillBeSavedHookTemplate string
|
||||
|
||||
func TestConfigurationWillBeSavedHook(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2422,6 +2464,7 @@ func TestConfigurationWillBeSavedHook(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendPushNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
if testing.Short() {
|
||||
t.Skip("skipping TestSendPushNotification test in short mode")
|
||||
}
|
||||
@@ -2519,6 +2562,7 @@ func TestSendPushNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginServeMetrics(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t, StartMetrics)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2577,6 +2621,7 @@ func TestPluginServeMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginGetChannelsForTeamForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2680,6 +2725,7 @@ func TestPluginGetChannelsForTeamForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginPatchChannelMembersNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should be able to set fields for multiple members", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPluginCommand(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestConnCreateTimeout(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -21,6 +22,7 @@ func TestConnCreateTimeout(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShutdownPluginConns(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPluginDeadlock(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Single Plugin", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestHealthCheckJob(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -75,7 +75,9 @@ func setAppEnvironmentWithPlugins(t *testing.T, pluginCode []string, app *App, a
|
||||
}
|
||||
|
||||
func TestHookMessageWillBePosted(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("rejected", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -116,6 +118,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("rejected, returned post ignored", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -157,6 +160,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("allowed", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -200,6 +204,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("updated", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -244,6 +249,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("multiple updated", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -307,6 +313,7 @@ func TestHookMessageWillBePosted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookMessageHasBeenPosted(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -350,6 +357,7 @@ func TestHookMessageHasBeenPosted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookMessageWillBeUpdated(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -395,6 +403,7 @@ func TestHookMessageWillBeUpdated(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookMessageHasBeenUpdated(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -443,6 +452,7 @@ func TestHookMessageHasBeenUpdated(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookMessageHasBeenDeleted(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -488,7 +498,9 @@ func TestHookMessageHasBeenDeleted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookFileWillBeUploaded(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("rejected", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -533,6 +545,7 @@ func TestHookFileWillBeUploaded(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("rejected, returned file ignored", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -583,6 +596,7 @@ func TestHookFileWillBeUploaded(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("allowed", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -639,6 +653,7 @@ func TestHookFileWillBeUploaded(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("updated", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -712,6 +727,7 @@ func TestHookFileWillBeUploaded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserWillLogIn_Blocked(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -751,6 +767,7 @@ func TestUserWillLogIn_Blocked(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserWillLogInIn_Passed(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -793,6 +810,7 @@ func TestUserWillLogInIn_Passed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserHasLoggedIn(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -840,6 +858,7 @@ func TestUserHasLoggedIn(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserHasBeenDeactivated(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -889,6 +908,7 @@ func TestUserHasBeenDeactivated(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserHasBeenCreated(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -934,6 +954,7 @@ func TestUserHasBeenCreated(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestErrorString(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1008,6 +1029,7 @@ func TestErrorString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookContext(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
@@ -1063,6 +1085,7 @@ func TestHookContext(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestActiveHooks(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1134,6 +1157,7 @@ func TestActiveHooks(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookMetrics(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1233,6 +1257,7 @@ func TestHookMetrics(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookReactionHasBeenAdded(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1276,6 +1301,7 @@ func TestHookReactionHasBeenAdded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookReactionHasBeenRemoved(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1325,6 +1351,7 @@ func TestHookReactionHasBeenRemoved(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookRunDataRetention(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1370,6 +1397,7 @@ func TestHookRunDataRetention(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookOnSendDailyTelemetry(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1414,6 +1442,7 @@ func TestHookOnSendDailyTelemetry(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookOnCloudLimitsUpdated(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1462,6 +1491,7 @@ func TestHookOnCloudLimitsUpdated(t *testing.T) {
|
||||
var hookNotificationWillBePushedTmpl string
|
||||
|
||||
func TestHookNotificationWillBePushed(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
if testing.Short() {
|
||||
t.Skip("skipping TestHookNotificationWillBePushed test in short mode")
|
||||
}
|
||||
@@ -1492,6 +1522,8 @@ func TestHookNotificationWillBePushed(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1586,6 +1618,8 @@ func TestHookNotificationWillBePushed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookMessagesWillBeConsumed(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
setupPlugin := func(t *testing.T, th *TestHelper) {
|
||||
var mockAPI plugintest.API
|
||||
mockAPI.On("LoadPluginConfiguration", mock.Anything).Return(nil)
|
||||
@@ -1618,10 +1652,11 @@ func TestHookMessagesWillBeConsumed(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("feature flag disabled", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CONSUMEPOSTHOOK", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CONSUMEPOSTHOOK")
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := SetupConfig(t, func(cfg *model.Config) {
|
||||
cfg.FeatureFlags.ConsumePostHook = false
|
||||
}).InitBasic()
|
||||
t.Cleanup(th.TearDown)
|
||||
|
||||
setupPlugin(t, th)
|
||||
@@ -1641,10 +1676,12 @@ func TestHookMessagesWillBeConsumed(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("feature flag enabled", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_CONSUMEPOSTHOOK", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_CONSUMEPOSTHOOK")
|
||||
mainHelper.Parallel(t)
|
||||
|
||||
th := SetupConfig(t, func(cfg *model.Config) {
|
||||
cfg.FeatureFlags.ConsumePostHook = true
|
||||
}).InitBasic()
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
t.Cleanup(th.TearDown)
|
||||
|
||||
setupPlugin(t, th)
|
||||
@@ -1665,7 +1702,9 @@ func TestHookMessagesWillBeConsumed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHookPreferencesHaveChanged(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should be called when preferences are changed by non-plugin code", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1734,6 +1773,7 @@ func TestHookPreferencesHaveChanged(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should be called when preferences are changed by plugin code", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1819,6 +1859,7 @@ func TestHookPreferencesHaveChanged(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChannelHasBeenCreated(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
getPluginCode := func(th *TestHelper) string {
|
||||
return `
|
||||
package main
|
||||
@@ -1856,6 +1897,7 @@ func TestChannelHasBeenCreated(t *testing.T) {
|
||||
pluginManifest := `{"id": "testplugin", "server": {"executable": "backend.exe"}}`
|
||||
|
||||
t.Run("should call hook when a regular channel is created", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1886,6 +1928,7 @@ func TestChannelHasBeenCreated(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should call hook when a DM is created", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1911,6 +1954,7 @@ func TestChannelHasBeenCreated(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should call hook when a GM is created", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1938,6 +1982,7 @@ func TestChannelHasBeenCreated(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserHasJoinedChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
getPluginCode := func(th *TestHelper) string {
|
||||
return `
|
||||
package main
|
||||
@@ -1982,6 +2027,7 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
pluginManifest := `{"id": "testplugin", "server": {"executable": "backend.exe"}}`
|
||||
|
||||
t.Run("should call hook when a user joins an existing channel", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2027,6 +2073,7 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should call hook when a user is added to an existing channel", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2072,6 +2119,7 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not call hook when a regular channel is created", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2106,6 +2154,7 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not call hook when a DM is created", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2136,6 +2185,7 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not call hook when a GM is created", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils/fileutils"
|
||||
)
|
||||
|
||||
type nilReadSeeker struct {
|
||||
}
|
||||
type nilReadSeeker struct{}
|
||||
|
||||
func (r *nilReadSeeker) Read(p []byte) (int, error) {
|
||||
return 0, io.EOF
|
||||
@@ -69,6 +68,7 @@ func (b byBundleInfoID) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
|
||||
func (b byBundleInfoID) Less(i, j int) bool { return b[i].Manifest.Id < b[j].Manifest.Id }
|
||||
|
||||
func TestInstallPluginLocally(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("invalid tar", func(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
@@ -268,6 +268,7 @@ func TestInstallPluginLocally(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstallPluginAlreadyActive(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPluginShutdownTest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test to verify forced shutdown of slow plugin")
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPluginPublicKeys(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -64,6 +65,7 @@ func TestPluginPublicKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVerifySignature(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
path, _ := fileutils.FindDir("tests")
|
||||
pluginFilename := "testplugin.tar.gz"
|
||||
signatureFilename := "testplugin.tar.gz.sig"
|
||||
|
||||
@@ -38,6 +38,7 @@ func getHashedKey(key string) string {
|
||||
}
|
||||
|
||||
func TestPluginKeyValueStore(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -138,6 +139,7 @@ func TestPluginKeyValueStore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginKeyValueStoreCompareAndSet(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -195,6 +197,7 @@ func TestPluginKeyValueStoreCompareAndSet(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginKeyValueStoreSetWithOptionsJSON(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
pluginID := "testpluginid"
|
||||
|
||||
t.Run("storing a value without providing options works", func(t *testing.T) {
|
||||
@@ -339,6 +342,7 @@ func TestPluginKeyValueStoreSetWithOptionsJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServePluginRequest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -351,6 +355,7 @@ func TestServePluginRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrivateServePluginRequest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -396,6 +401,7 @@ func TestPrivateServePluginRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHandlePluginRequest(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -443,6 +449,7 @@ func TestHandlePluginRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPluginStatusesDisabled(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -456,6 +463,7 @@ func TestGetPluginStatusesDisabled(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPluginStatuses(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -469,6 +477,7 @@ func TestGetPluginStatuses(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginSync(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -632,6 +641,7 @@ func TestPluginSync(t *testing.T) {
|
||||
|
||||
// See https://github.com/mattermost/mattermost-server/issues/19189
|
||||
func TestChannelsPluginsInit(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -661,6 +671,7 @@ func TestChannelsPluginsInit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSyncPluginsActiveState(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -720,6 +731,7 @@ func TestSyncPluginsActiveState(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginPanicLogs(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should panic", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -768,6 +780,7 @@ func TestPluginPanicLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginStatusActivateError(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should return error from OnActivate in plugin statuses", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -818,6 +831,7 @@ func (a pluginStatusById) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a pluginStatusById) Less(i, j int) bool { return a[i].PluginId < a[j].PluginId }
|
||||
|
||||
func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// Find the tests folder before we change directories to the temporary workspace.
|
||||
testsPath, _ := fileutils.FindDir("tests")
|
||||
|
||||
@@ -827,18 +841,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
th := Setup(t)
|
||||
t.Cleanup(th.TearDown)
|
||||
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
err = os.Chdir(wd)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
err = os.Chdir(th.tempWorkspace)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Make a prepackaged_plugins directory for use with the tests.
|
||||
err = os.Mkdir(prepackagedPluginsDir, os.ModePerm)
|
||||
err := os.Mkdir(filepath.Join(th.tempWorkspace, prepackagedPluginsDir), os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -855,7 +859,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
appErr := th.App.ch.syncPlugins()
|
||||
require.Nil(t, appErr)
|
||||
|
||||
err := th.App.ch.processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
err := th.App.ch.processPrepackagedPlugins(filepath.Join(th.tempWorkspace, prepackagedPluginsDir))
|
||||
require.NoError(t, err)
|
||||
|
||||
env := th.App.GetPluginsEnvironment()
|
||||
@@ -865,22 +869,22 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
return plugins, transitionalPlugins
|
||||
}
|
||||
|
||||
copyAsPrepackagedPlugin := func(t *testing.T, filename string) {
|
||||
copyAsPrepackagedPlugin := func(t *testing.T, th *TestHelper, filename string) {
|
||||
t.Helper()
|
||||
|
||||
err := testlib.CopyFile(filepath.Join(testsPath, filename), filepath.Join(prepackagedPluginsDir, filename))
|
||||
err := testlib.CopyFile(filepath.Join(testsPath, filename), filepath.Join(th.tempWorkspace, prepackagedPluginsDir, filename))
|
||||
require.NoError(t, err)
|
||||
|
||||
err = testlib.CopyFile(filepath.Join(testsPath, fmt.Sprintf("%s.sig", filename)), filepath.Join(prepackagedPluginsDir, fmt.Sprintf("%s.sig", filename)))
|
||||
err = testlib.CopyFile(filepath.Join(testsPath, fmt.Sprintf("%s.sig", filename)), filepath.Join(th.tempWorkspace, prepackagedPluginsDir, fmt.Sprintf("%s.sig", filename)))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
copyAsFilestorePlugin := func(t *testing.T, bundleFilename, pluginID string) {
|
||||
copyAsFilestorePlugin := func(t *testing.T, th *TestHelper, bundleFilename, pluginID string) {
|
||||
t.Helper()
|
||||
|
||||
err := testlib.CopyFile(filepath.Join(testsPath, bundleFilename), filepath.Join(fmt.Sprintf("data/plugins/%s.tar.gz", pluginID)))
|
||||
err := testlib.CopyFile(filepath.Join(testsPath, bundleFilename), filepath.Join(*th.App.Config().FileSettings.Directory, fmt.Sprintf("plugins/%s.tar.gz", pluginID)))
|
||||
require.NoError(t, err)
|
||||
err = testlib.CopyFile(filepath.Join(testsPath, fmt.Sprintf("%s.sig", bundleFilename)), filepath.Join(fmt.Sprintf("data/plugins/%s.tar.gz.sig", pluginID)))
|
||||
err = testlib.CopyFile(filepath.Join(testsPath, fmt.Sprintf("%s.sig", bundleFilename)), filepath.Join(*th.App.Config().FileSettings.Directory, fmt.Sprintf("plugins/%s.tar.gz.sig", pluginID)))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -892,13 +896,13 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Equal(t, version, actual.Manifest.Version)
|
||||
}
|
||||
|
||||
expectPluginInFilestore := func(t *testing.T, pluginID, version string) {
|
||||
expectPluginInFilestore := func(t *testing.T, th *TestHelper, pluginID, version string) {
|
||||
t.Helper()
|
||||
|
||||
bundlePath := fmt.Sprintf("data/plugins/%s.tar.gz", pluginID)
|
||||
bundlePath := filepath.Join(*th.App.Config().FileSettings.Directory, fmt.Sprintf("plugins/%s.tar.gz", pluginID))
|
||||
|
||||
require.FileExists(t, bundlePath)
|
||||
require.FileExists(t, fmt.Sprintf("data/plugins/%s.tar.gz.sig", pluginID))
|
||||
require.FileExists(t, filepath.Join(*th.App.Config().FileSettings.Directory, fmt.Sprintf("plugins/%s.tar.gz.sig", pluginID)))
|
||||
|
||||
// Verify the version recorded in the Manifest
|
||||
f, err := os.Open(bundlePath)
|
||||
@@ -930,11 +934,11 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Equal(t, version, manifest.Version)
|
||||
}
|
||||
|
||||
expectPluginNotInFilestore := func(t *testing.T, pluginID string) {
|
||||
expectPluginNotInFilestore := func(t *testing.T, th *TestHelper, pluginID string) {
|
||||
t.Helper()
|
||||
|
||||
require.NoFileExists(t, fmt.Sprintf("data/plugins/%s.tar.gz", pluginID))
|
||||
require.NoFileExists(t, fmt.Sprintf("data/plugins/%s.tar.gz.sig", pluginID))
|
||||
require.NoFileExists(t, filepath.Join(*th.App.Config().FileSettings.Directory, fmt.Sprintf("plugins/%s.tar.gz", pluginID)))
|
||||
require.NoFileExists(t, filepath.Join(*th.App.Config().FileSettings.Directory, fmt.Sprintf("plugins/%s.tar.gz.sig", pluginID)))
|
||||
}
|
||||
|
||||
expectPluginStatus := func(t *testing.T, pluginID, version string, actual *model.PluginStatus) {
|
||||
@@ -953,7 +957,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 1, "expected one prepackaged plugin")
|
||||
@@ -965,7 +969,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Len(t, pluginStatus, 1)
|
||||
expectPluginStatus(t, "testplugin", "0.0.1", pluginStatus[0])
|
||||
|
||||
expectPluginNotInFilestore(t, "testplugin")
|
||||
expectPluginNotInFilestore(t, th, "testplugin")
|
||||
})
|
||||
|
||||
t.Run("single plugin, not automatically installed since not enabled", func(t *testing.T) {
|
||||
@@ -976,7 +980,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
*cfg.PluginSettings.AutomaticPrepackagedPlugins = true
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 1, "expected one prepackaged plugin")
|
||||
@@ -987,7 +991,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, pluginStatus, 0)
|
||||
|
||||
expectPluginNotInFilestore(t, "testplugin")
|
||||
expectPluginNotInFilestore(t, th, "testplugin")
|
||||
})
|
||||
|
||||
t.Run("single plugin, not automatically installed despite enabled since automatic prepackaged plugins disabled", func(t *testing.T) {
|
||||
@@ -999,7 +1003,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 1, "expected one prepackaged plugin")
|
||||
@@ -1010,7 +1014,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, pluginStatus, 0)
|
||||
|
||||
expectPluginNotInFilestore(t, "testplugin")
|
||||
expectPluginNotInFilestore(t, th, "testplugin")
|
||||
})
|
||||
|
||||
t.Run("multiple plugins, some automatically installed since enabled", func(t *testing.T) {
|
||||
@@ -1022,8 +1026,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin2"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, "testplugin2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin2.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 2, "expected two prepackaged plugins")
|
||||
@@ -1037,8 +1041,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Len(t, pluginStatus, 1)
|
||||
expectPluginStatus(t, "testplugin2", "1.2.3", pluginStatus[0])
|
||||
|
||||
expectPluginNotInFilestore(t, "testplugin")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginNotInFilestore(t, th, "testplugin")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("multiple plugins, one previously installed, all now installed", func(t *testing.T) {
|
||||
@@ -1049,15 +1053,15 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
*cfg.PluginSettings.AutomaticPrepackagedPlugins = true
|
||||
})
|
||||
|
||||
copyAsFilestorePlugin(t, "testplugin.tar.gz", "testplugin")
|
||||
copyAsFilestorePlugin(t, th, "testplugin.tar.gz", "testplugin")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
cfg.PluginSettings.PluginStates["testplugin2"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, "testplugin2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin2.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 2, "expected two prepackaged plugins")
|
||||
@@ -1075,8 +1079,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
expectPluginStatus(t, "testplugin", "0.0.1", pluginStatus[0])
|
||||
expectPluginStatus(t, "testplugin2", "1.2.3", pluginStatus[1])
|
||||
|
||||
expectPluginInFilestore(t, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginInFilestore(t, th, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("multiple plugins, one previously installed and now upgraded, all now installed", func(t *testing.T) {
|
||||
@@ -1087,18 +1091,18 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
*cfg.PluginSettings.AutomaticPrepackagedPlugins = true
|
||||
})
|
||||
|
||||
copyAsFilestorePlugin(t, "testplugin.tar.gz", "testplugin")
|
||||
copyAsFilestorePlugin(t, th, "testplugin.tar.gz", "testplugin")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
cfg.PluginSettings.PluginStates["testplugin2"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin-v0.0.2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, "testplugin2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin-v0.0.2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin2.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
err := th.App.ch.processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
err := th.App.ch.processPrepackagedPlugins(filepath.Join(th.tempWorkspace, prepackagedPluginsDir))
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, plugins, 2, "expected two prepackaged plugins")
|
||||
@@ -1116,8 +1120,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
expectPluginStatus(t, "testplugin", "0.0.2", pluginStatus[0])
|
||||
expectPluginStatus(t, "testplugin2", "1.2.3", pluginStatus[1])
|
||||
|
||||
expectPluginInFilestore(t, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginInFilestore(t, th, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("multiple plugins, one previously installed but prepackaged is older, all now installed", func(t *testing.T) {
|
||||
@@ -1128,15 +1132,15 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
*cfg.PluginSettings.AutomaticPrepackagedPlugins = true
|
||||
})
|
||||
|
||||
copyAsFilestorePlugin(t, "testplugin-v0.0.2.tar.gz", "testplugin")
|
||||
copyAsFilestorePlugin(t, th, "testplugin-v0.0.2.tar.gz", "testplugin")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
cfg.PluginSettings.PluginStates["testplugin2"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, "testplugin2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin2.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 2, "expected two prepackaged plugins")
|
||||
@@ -1154,8 +1158,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
expectPluginStatus(t, "testplugin", "0.0.2", pluginStatus[0])
|
||||
expectPluginStatus(t, "testplugin2", "1.2.3", pluginStatus[1])
|
||||
|
||||
expectPluginInFilestore(t, "testplugin", "0.0.2")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginInFilestore(t, th, "testplugin", "0.0.2")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("multiple plugins, not automatically installed despite enabled since automatic prepackaged plugins disabled", func(t *testing.T) {
|
||||
@@ -1168,8 +1172,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin2"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, "testplugin2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin2.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 2, "expected two prepackaged plugins")
|
||||
@@ -1182,8 +1186,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Len(t, pluginStatus, 0)
|
||||
|
||||
expectPluginNotInFilestore(t, "testplugin")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginNotInFilestore(t, th, "testplugin")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("removing a prepackaged plugin leaves it disabled", func(t *testing.T) {
|
||||
@@ -1196,8 +1200,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin2"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, "testplugin2.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin2.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Len(t, plugins, 2, "expected two prepackaged plugins")
|
||||
@@ -1235,8 +1239,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Len(t, pluginStatus, 1)
|
||||
expectPluginStatus(t, "testplugin2", "1.2.3", pluginStatus[0])
|
||||
|
||||
expectPluginNotInFilestore(t, "testplugin")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginNotInFilestore(t, th, "testplugin")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("single transitional plugin automatically installed and persisted since enabled", func(t *testing.T) {
|
||||
@@ -1254,7 +1258,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Empty(t, plugins)
|
||||
@@ -1266,8 +1270,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Len(t, pluginStatus, 1)
|
||||
expectPluginStatus(t, "testplugin", "0.0.1", pluginStatus[0])
|
||||
|
||||
expectPluginInFilestore(t, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginInFilestore(t, th, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("single transitional plugin not persisted since already in filestore", func(t *testing.T) {
|
||||
@@ -1285,8 +1289,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsFilestorePlugin(t, "testplugin.tar.gz", "testplugin")
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsFilestorePlugin(t, th, "testplugin.tar.gz", "testplugin")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Empty(t, plugins)
|
||||
@@ -1297,8 +1301,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Len(t, pluginStatus, 1)
|
||||
expectPluginStatus(t, "testplugin", "0.0.1", pluginStatus[0])
|
||||
|
||||
expectPluginInFilestore(t, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginInFilestore(t, th, "testplugin", "0.0.1")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("single transitional plugin persisted since newer than filestore", func(t *testing.T) {
|
||||
@@ -1316,8 +1320,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsFilestorePlugin(t, "testplugin.tar.gz", "testplugin")
|
||||
copyAsPrepackagedPlugin(t, "testplugin-v0.0.2.tar.gz")
|
||||
copyAsFilestorePlugin(t, th, "testplugin.tar.gz", "testplugin")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin-v0.0.2.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Empty(t, plugins)
|
||||
@@ -1329,8 +1333,8 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
require.Len(t, pluginStatus, 1)
|
||||
expectPluginStatus(t, "testplugin", "0.0.2", pluginStatus[0])
|
||||
|
||||
expectPluginInFilestore(t, "testplugin", "0.0.2")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginInFilestore(t, th, "testplugin", "0.0.2")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
|
||||
t.Run("transitional plugins persisted only once", func(t *testing.T) {
|
||||
@@ -1348,7 +1352,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
cfg.PluginSettings.PluginStates["testplugin"] = &model.PluginState{Enable: true}
|
||||
})
|
||||
|
||||
copyAsPrepackagedPlugin(t, "testplugin.tar.gz")
|
||||
copyAsPrepackagedPlugin(t, th, "testplugin.tar.gz")
|
||||
|
||||
plugins, transitionalPlugins := initPlugins(t, th)
|
||||
require.Empty(t, plugins)
|
||||
@@ -1364,12 +1368,13 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
|
||||
th.App.ch.persistTransitionallyPrepackagedPlugins()
|
||||
|
||||
expectPluginNotInFilestore(t, "testplugin")
|
||||
expectPluginNotInFilestore(t, "testplugin2")
|
||||
expectPluginNotInFilestore(t, th, "testplugin")
|
||||
expectPluginNotInFilestore(t, th, "testplugin2")
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetPluginStateOverride(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1387,10 +1392,10 @@ func TestGetPluginStateOverride(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with enabled flag set to true", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_APPSENABLED", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_APPSENABLED")
|
||||
|
||||
th2 := Setup(t)
|
||||
mainHelper.Parallel(t)
|
||||
th2 := SetupConfig(t, func(cfg *model.Config) {
|
||||
cfg.FeatureFlags.AppsEnabled = true
|
||||
})
|
||||
defer th2.TearDown()
|
||||
|
||||
overrides, value := th2.App.ch.getPluginStateOverride("com.mattermost.apps")
|
||||
@@ -1399,10 +1404,10 @@ func TestGetPluginStateOverride(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with enabled flag set to false", func(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_APPSENABLED", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_APPSENABLED")
|
||||
|
||||
th2 := Setup(t)
|
||||
mainHelper.Parallel(t)
|
||||
th2 := SetupConfig(t, func(cfg *model.Config) {
|
||||
cfg.FeatureFlags.AppsEnabled = false
|
||||
})
|
||||
defer th2.TearDown()
|
||||
|
||||
overrides, value := th2.App.ch.getPluginStateOverride("com.mattermost.apps")
|
||||
|
||||
@@ -26,9 +26,10 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/telemetry"
|
||||
)
|
||||
|
||||
var pendingPostIDsCacheTTL = 30 * time.Second
|
||||
|
||||
const (
|
||||
PendingPostIDsCacheSize = 25000
|
||||
PendingPostIDsCacheTTL = 30 * time.Second
|
||||
PageDefault = 0
|
||||
)
|
||||
|
||||
@@ -146,7 +147,7 @@ func (a *App) deduplicateCreatePost(rctx request.CTX, post *model.Post) (foundPo
|
||||
var postID string
|
||||
nErr := a.Srv().seenPendingPostIdsCache.Get(post.PendingPostId, &postID)
|
||||
if nErr == cache.ErrKeyNotFound {
|
||||
if appErr := a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, unknownPostId, PendingPostIDsCacheTTL); appErr != nil {
|
||||
if appErr := a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, unknownPostId, pendingPostIDsCacheTTL); appErr != nil {
|
||||
return nil, model.NewAppError("deduplicateCreatePost", "api.post.deduplicate_create_post.cache_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
|
||||
}
|
||||
return nil, nil
|
||||
@@ -205,7 +206,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel
|
||||
return
|
||||
}
|
||||
|
||||
if appErr := a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, savedPost.Id, PendingPostIDsCacheTTL); appErr != nil {
|
||||
if appErr := a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, savedPost.Id, pendingPostIDsCacheTTL); appErr != nil {
|
||||
err = model.NewAppError("CreatePost", "api.post.deduplicate_create_post.cache_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
|
||||
}
|
||||
}()
|
||||
@@ -371,7 +372,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel
|
||||
|
||||
// Update the mapping from pending post id to the actual post id, for any clients that
|
||||
// might be duplicating requests.
|
||||
if appErr := a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, rpost.Id, PendingPostIDsCacheTTL); appErr != nil {
|
||||
if appErr := a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, rpost.Id, pendingPostIDsCacheTTL); appErr != nil {
|
||||
return nil, model.NewAppError("CreatePost", "api.post.deduplicate_create_post.cache_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
|
||||
}
|
||||
|
||||
@@ -1383,6 +1384,7 @@ func (a *App) AddCursorIdsForPostList(originalList *model.PostList, afterPost, b
|
||||
originalList.NextPostId = nextPostId
|
||||
originalList.PrevPostId = prevPostId
|
||||
}
|
||||
|
||||
func (a *App) GetPostsForChannelAroundLastUnread(c request.CTX, channelID, userID string, limitBefore, limitAfter int, skipFetchThreads bool, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, *model.AppError) {
|
||||
var lastViewedAt int64
|
||||
var err *model.AppError
|
||||
@@ -2156,7 +2158,6 @@ func (a *App) GetPostsByIds(postIDs []string) ([]*model.Post, int64, *model.AppE
|
||||
|
||||
func (a *App) GetEditHistoryForPost(postID string) ([]*model.Post, *model.AppError) {
|
||||
posts, err := a.Srv().Store().Post().GetEditHistoryForPost(postID)
|
||||
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
|
||||
@@ -12,12 +12,14 @@ import (
|
||||
)
|
||||
|
||||
func TestPostAcknowledgementsApp(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("SaveAcknowledgementForPost", func(t *testing.T) { testSaveAcknowledgementForPost(t) })
|
||||
t.Run("DeleteAcknowledgementForPost", func(t *testing.T) { testDeleteAcknowledgementForPost(t) })
|
||||
t.Run("GetAcknowledgementsForPostList", func(t *testing.T) { testGetAcknowledgementsForPostList(t) })
|
||||
}
|
||||
|
||||
func testSaveAcknowledgementForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -60,6 +62,7 @@ func testSaveAcknowledgementForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func testDeleteAcknowledgementForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
post, err1 := th.App.CreatePostAsUser(th.Context, &model.Post{
|
||||
@@ -126,6 +129,7 @@ func testDeleteAcknowledgementForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func testGetAcknowledgementsForPostList(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
p1, err := th.App.CreatePostAsUser(th.Context, &model.Post{
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProcessPostFileChanges(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ import (
|
||||
)
|
||||
|
||||
func TestGetTimeSortedPostAccessibleBounds(t *testing.T) {
|
||||
var postFromCreateAt = func(at int64) *model.Post {
|
||||
mainHelper.Parallel(t)
|
||||
postFromCreateAt := func(at int64) *model.Post {
|
||||
return &model.Post{CreateAt: at}
|
||||
}
|
||||
|
||||
@@ -193,6 +194,7 @@ func TestGetTimeSortedPostAccessibleBounds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFilterInaccessiblePosts(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
err := th.App.Srv().Store().System().Save(&model.System{
|
||||
@@ -203,7 +205,7 @@ func TestFilterInaccessiblePosts(t *testing.T) {
|
||||
|
||||
defer th.TearDown()
|
||||
|
||||
var postFromCreateAt = func(at int64) *model.Post {
|
||||
postFromCreateAt := func(at int64) *model.Post {
|
||||
return &model.Post{CreateAt: at}
|
||||
}
|
||||
|
||||
@@ -322,6 +324,7 @@ func TestFilterInaccessiblePosts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetFilteredAccessiblePosts(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
err := th.App.Srv().Store().System().Save(&model.System{
|
||||
@@ -332,7 +335,7 @@ func TestGetFilteredAccessiblePosts(t *testing.T) {
|
||||
|
||||
defer th.TearDown()
|
||||
|
||||
var postFromCreateAt = func(at int64) *model.Post {
|
||||
postFromCreateAt := func(at int64) *model.Post {
|
||||
return &model.Post{CreateAt: at}
|
||||
}
|
||||
|
||||
@@ -364,6 +367,7 @@ func TestGetFilteredAccessiblePosts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsInaccessiblePost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
err := th.App.Srv().Store().System().Save(&model.System{
|
||||
@@ -386,6 +390,7 @@ func TestIsInaccessiblePost(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_getInaccessibleRange(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
type test struct {
|
||||
label string
|
||||
bounds accessibleBounds
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPreparePostListForClient(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// Most of this logic is covered by TestPreparePostForClient, so this just tests handling of multiple posts
|
||||
|
||||
th := Setup(t)
|
||||
@@ -68,6 +69,7 @@ func TestPreparePostListForClient(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPreparePostForClient(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
var serverURL string
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
@@ -862,6 +864,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPreparePostForClientWithImageProxy(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
setup := func(t *testing.T) *TestHelper {
|
||||
th := Setup(t).InitBasic()
|
||||
|
||||
@@ -981,6 +984,7 @@ func testProxyOpenGraphImage(t *testing.T, th *TestHelper, shouldProxy bool) {
|
||||
}
|
||||
|
||||
func TestGetEmbedForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == "/index.html" {
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
@@ -1157,6 +1161,7 @@ func TestGetEmbedForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetImagesForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("with an image link", func(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
@@ -1445,6 +1450,7 @@ func TestGetImagesForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetEmojiNamesForString(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testCases := []struct {
|
||||
Description string
|
||||
Input string
|
||||
@@ -1496,6 +1502,7 @@ func TestGetEmojiNamesForString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetEmojiNamesForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testCases := []struct {
|
||||
Description string
|
||||
Post *model.Post
|
||||
@@ -1591,6 +1598,7 @@ func TestGetEmojiNamesForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCustomEmojisForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1670,6 +1678,7 @@ func TestGetCustomEmojisForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetFirstLinkAndImages(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1838,6 +1847,7 @@ func TestGetFirstLinkAndImages(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetImagesInMessageAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2623,6 +2633,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveMetadataURL(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
for _, test := range []struct {
|
||||
Name string
|
||||
RequestURL string
|
||||
@@ -2664,6 +2675,7 @@ func TestResolveMetadataURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseLinkMetadata(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2760,6 +2772,7 @@ func TestParseLinkMetadata(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseImages(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
for name, testCase := range map[string]struct {
|
||||
FileName string
|
||||
Expected *model.PostImage
|
||||
@@ -2879,6 +2892,7 @@ func TestParseImages(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLooksLikeAPermalink(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
const siteURLWithSubpath = "http://localhost:8065/foo"
|
||||
const siteURLWithTrailingSlash = "http://test.com/"
|
||||
const siteURL = "http://test.com"
|
||||
@@ -2910,6 +2924,7 @@ func TestLooksLikeAPermalink(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestContainsPermalink(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2949,6 +2964,7 @@ func TestContainsPermalink(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSanitizePostMetadataForUserAndChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3073,6 +3089,7 @@ func TestSanitizePostMetadataForUserAndChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSanitizePostMetaDataForAudit(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3125,6 +3142,7 @@ func TestSanitizePostMetaDataForAudit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSanitizePostMetadataForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestResolvePersistentNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should not delete when no posts exist", func(t *testing.T) {
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
@@ -148,6 +149,7 @@ func TestResolvePersistentNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeletePersistentNotification(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should not delete when no posts exist", func(t *testing.T) {
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
@@ -195,6 +197,7 @@ func TestDeletePersistentNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendPersistentNotifications(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestRestorePostVersion(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -195,6 +195,12 @@ func TestCreatePostDeduplicate(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("duplicate create post after cache expires is not idempotent", func(t *testing.T) {
|
||||
originalCacheTTL := pendingPostIDsCacheTTL
|
||||
pendingPostIDsCacheTTL = time.Second
|
||||
t.Cleanup(func() {
|
||||
pendingPostIDsCacheTTL = originalCacheTTL
|
||||
})
|
||||
|
||||
session := &model.Session{
|
||||
UserId: th.BasicUser.Id,
|
||||
}
|
||||
@@ -212,7 +218,7 @@ func TestCreatePostDeduplicate(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, "message", post.Message)
|
||||
|
||||
time.Sleep(PendingPostIDsCacheTTL)
|
||||
time.Sleep(pendingPostIDsCacheTTL)
|
||||
|
||||
duplicatePost, err := th.App.CreatePostAsUser(th.Context.WithSession(session), &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
@@ -276,6 +282,7 @@ func TestCreatePostDeduplicate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachFilesToPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should attach files", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -343,6 +350,7 @@ func TestAttachFilesToPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdatePostEditAt(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -365,6 +373,7 @@ func TestUpdatePostEditAt(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdatePostTimeLimit(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -399,6 +408,7 @@ func TestUpdatePostTimeLimit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdatePostInArchivedChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -413,6 +423,7 @@ func TestUpdatePostInArchivedChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// This test ensures that when replying to a root post made by a user who has since left the channel, the reply
|
||||
// post completes successfully. This is a regression test for PLT-6523.
|
||||
th := Setup(t).InitBasic()
|
||||
@@ -442,6 +453,7 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostAttachPostToChildPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -487,6 +499,7 @@ func TestPostAttachPostToChildPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdatePostPluginHooks(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -628,6 +641,7 @@ func TestUpdatePostPluginHooks(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostChannelMentions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -694,6 +708,7 @@ func TestPostChannelMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImageProxy(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -817,6 +832,7 @@ func TestImageProxy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeletePostWithFileAttachments(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -861,6 +877,7 @@ func TestDeletePostWithFileAttachments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeletePostInArchivedChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -875,7 +892,9 @@ func TestDeletePostInArchivedChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreatePost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("call PreparePostForClient before returning", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -904,6 +923,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Sets prop MENTION_HIGHLIGHT_DISABLED when it should", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.AddUserToChannel(th.BasicUser, th.BasicChannel)
|
||||
@@ -956,6 +976,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Sets PostPropsPreviewedPost when a permalink is the first link", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.AddUserToChannel(th.BasicUser, th.BasicChannel)
|
||||
@@ -991,6 +1012,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("creates a single record for a permalink preview post", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1030,6 +1052,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("sanitizes post metadata appropriately", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1092,6 +1115,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should not allow to create posts on shared DMs", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := setupSharedChannels(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1131,6 +1155,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should not allow to create posts on shared GMs", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := setupSharedChannels(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1171,6 +1196,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("MM-40016 should not panic with `concurrent map read and map write`", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1222,6 +1248,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should sanitize the force notifications prop if the flag is not set", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.AddUserToChannel(th.BasicUser, th.BasicChannel)
|
||||
@@ -1238,6 +1265,7 @@ func TestCreatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should add the force notifications prop if the flag is set", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.AddUserToChannel(th.BasicUser, th.BasicChannel)
|
||||
@@ -1254,7 +1282,9 @@ func TestCreatePost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("call PreparePostForClient before returning", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1291,6 +1321,7 @@ func TestPatchPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Sets Prop MENTION_HIGHLIGHT_DISABLED when it should", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1341,7 +1372,9 @@ func TestPatchPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreatePostAsUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("marks channel as viewed for regular user", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1365,6 +1398,7 @@ func TestCreatePostAsUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("does not mark channel as viewed for webhook from user", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1389,6 +1423,7 @@ func TestCreatePostAsUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("does not mark channel as viewed for bot user in channel", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1420,6 +1455,7 @@ func TestCreatePostAsUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("does not log warning for bot user not in channel", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1445,6 +1481,7 @@ func TestCreatePostAsUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("marks channel as viewed for reply post when CRT is off", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1480,6 +1517,7 @@ func TestCreatePostAsUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("does not mark channel as viewed for reply post when CRT is on", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1517,6 +1555,7 @@ func TestCreatePostAsUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchPostInArchivedChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1531,7 +1570,9 @@ func TestPatchPostInArchivedChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateEphemeralPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Post contains preview if the user has permissions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.AddUserToChannel(th.BasicUser, th.BasicChannel)
|
||||
@@ -1566,6 +1607,7 @@ func TestUpdateEphemeralPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Post does not contain preview if the user has no permissions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
privateChannel := th.CreatePrivateChannel(th.Context, th.BasicTeam)
|
||||
@@ -1601,7 +1643,9 @@ func TestUpdateEphemeralPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdatePost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("call PreparePostForClient before returning", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1637,6 +1681,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Sets PostPropsPreviewedPost when a post is updated to have a permalink as the first link", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.AddUserToChannel(th.BasicUser, th.BasicChannel)
|
||||
@@ -1676,6 +1721,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("sanitizes post metadata appropriately", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1741,6 +1787,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchPostsForUser(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
perPage := 5
|
||||
searchTerm := "searchTerm"
|
||||
|
||||
@@ -1777,6 +1824,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("should return everything as first page of posts from database", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, posts := setup(t, false)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1797,6 +1845,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not return later pages of posts from database", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, _ := setup(t, false)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1809,6 +1858,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return first page of posts from ElasticSearch", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, posts := setup(t, true)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1839,6 +1889,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return later pages of posts from ElasticSearch", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, posts := setup(t, true)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1866,6 +1917,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should fall back to database if ElasticSearch fails on first page", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, posts := setup(t, true)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1898,6 +1950,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return nothing if ElasticSearch fails on later pages", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, _ := setup(t, true)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1922,6 +1975,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return the same results if there is a tilde in the channel name", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, _ := setup(t, false)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1943,6 +1997,7 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return the same results if there is an 'at' in the user", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th, _ := setup(t, false)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1965,7 +2020,9 @@ func TestSearchPostsForUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCountMentionsFromPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should not count posts without mentions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2001,6 +2058,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count keyword mentions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2040,6 +2098,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count channel-wide mentions when enabled", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2079,6 +2138,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not count channel-wide mentions when disabled for user", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2116,6 +2176,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not count channel-wide mentions when disabled for channel", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2158,6 +2219,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count comment mentions when using COMMENTS_NOTIFY_ROOT", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2212,6 +2274,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count comment mentions when using COMMENTS_NOTIFY_ANY", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2266,6 +2329,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count mentions caused by being added to the channel", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2315,6 +2379,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return the number of posts made by the other user for a direct channel", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2350,6 +2415,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should return the number of posts made by the other user for a group message", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2393,6 +2459,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not count mentions from the before the given post", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2430,6 +2497,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not count mentions from the user's own posts", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2461,6 +2529,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should include comments made before the given post when counting comment mentions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2508,6 +2577,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not include comments made before the given post when rootPost is inaccessible", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2568,6 +2638,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count mentions from the user's webhook posts", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2608,6 +2679,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count multiple pages of mentions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2644,6 +2716,7 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should count urgent mentions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2700,7 +2773,9 @@ func TestCountMentionsFromPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFillInPostProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should not add disable group highlight to post props for user with group mention permissions", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
@@ -2723,6 +2798,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not add disable group highlight to post props for app without license", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2755,6 +2831,7 @@ func TestFillInPostProps(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should add disable group highlight to post props for guest user", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
@@ -2789,7 +2866,9 @@ func TestFillInPostProps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestThreadMembership(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("should update memberships for conversation participants", func(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -2850,6 +2929,7 @@ func TestThreadMembership(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFollowThreadSkipsParticipants(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2919,6 +2999,7 @@ func TestFollowThreadSkipsParticipants(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAutofollowBasedOnRootPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2947,6 +3028,7 @@ func TestAutofollowBasedOnRootPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestViewChannelShouldNotUpdateThreads(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -2981,6 +3063,7 @@ func TestViewChannelShouldNotUpdateThreads(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCollapsedThreadFetch(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3197,6 +3280,7 @@ func TestReplyToPostWithLag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSharedChannelSyncForPostActions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("creating a post in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
|
||||
th := setupSharedChannels(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -3281,6 +3365,7 @@ func TestSharedChannelSyncForPostActions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAutofollowOnPostingAfterUnfollow(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3322,6 +3407,7 @@ func TestAutofollowOnPostingAfterUnfollow(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPostIfAuthorized(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3386,6 +3472,7 @@ func TestGetPostIfAuthorized(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShouldNotRefollowOnOthersReply(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3435,6 +3522,7 @@ func TestShouldNotRefollowOnOthersReply(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLastAccessiblePostTime(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3468,6 +3556,7 @@ func TestGetLastAccessiblePostTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestComputeLastAccessiblePostTime(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("Updates the time, if cloud limit is applicable", func(t *testing.T) {
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
@@ -3525,6 +3614,7 @@ func TestComputeLastAccessiblePostTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetEditHistoryForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3666,6 +3756,7 @@ func TestGetEditHistoryForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyWranglerPostlist(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3718,6 +3809,7 @@ func TestCopyWranglerPostlist(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateMoveOrCopy(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3842,6 +3934,7 @@ func TestValidateMoveOrCopy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPermanentDeletePost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -3933,6 +4026,7 @@ func TestPermanentDeletePost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendTestMessage(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
t.Run("Should create the post with the correct prop", func(t *testing.T) {
|
||||
@@ -3943,6 +4037,7 @@ func TestSendTestMessage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPopulateEditHistoryFileMetadata(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNoticeValidation(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := SetupWithStoreMock(t)
|
||||
mockStore := th.App.Srv().Store().(*mocks.Store)
|
||||
mockRoleStore := mocks.RoleStore{}
|
||||
@@ -599,6 +600,7 @@ func TestNoticeValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoticeFetch(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ func genRateLimitSettings(useAuth, useIP bool, header string) *model.RateLimitSe
|
||||
}
|
||||
|
||||
func TestNewRateLimiterSuccess(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
settings := genRateLimitSettings(false, false, "")
|
||||
rateLimiter, err := NewRateLimiter(settings, nil)
|
||||
require.NotNil(t, rateLimiter)
|
||||
@@ -38,6 +39,7 @@ func TestNewRateLimiterSuccess(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewRateLimiterFailure(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
invalidSettings := genRateLimitSettings(false, false, "")
|
||||
invalidSettings.MaxBurst = model.NewPointer(-100)
|
||||
rateLimiter, err := NewRateLimiter(invalidSettings, nil)
|
||||
@@ -50,6 +52,7 @@ func TestNewRateLimiterFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerateKey(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
cases := []struct {
|
||||
useAuth bool
|
||||
useIP bool
|
||||
@@ -91,6 +94,7 @@ func TestGenerateKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerateKey_TrustedHeader(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
req := httptest.NewRequest("GET", "/", nil)
|
||||
req.RemoteAddr = "10.10.10.5:80"
|
||||
req.Header.Set("X-Forwarded-For", "10.6.3.1, 10.5.1.2")
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSaveReactionForPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
|
||||
post := th.CreatePost(th.BasicChannel)
|
||||
@@ -97,6 +98,7 @@ func TestSaveReactionForPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSharedChannelSyncForReactionActions(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("adding a reaction in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
|
||||
th := setupSharedChannels(t).InitBasic()
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ func setupRemoteCluster(tb testing.TB) *TestHelper {
|
||||
}
|
||||
|
||||
func TestAddRemoteCluster(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := setupRemoteCluster(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -41,6 +42,7 @@ func TestAddRemoteCluster(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateRemoteCluster(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := setupRemoteCluster(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ var testData []model.ReportableObject = []model.ReportableObject{
|
||||
}
|
||||
|
||||
func TestSaveReportChunk(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -69,6 +70,7 @@ func TestSaveReportChunk(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompileReportChunks(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -89,8 +91,7 @@ func TestCompileReportChunks(t *testing.T) {
|
||||
require.Nil(t, readErr)
|
||||
require.NotNil(t, bytes)
|
||||
|
||||
expected :=
|
||||
`Name,NumPosts,StartDate
|
||||
expected := `Name,NumPosts,StartDate
|
||||
some-name,400,2024-01-01
|
||||
some-other-name,500,2023-01-01
|
||||
some-other-other-name,600,2022-01-01
|
||||
@@ -110,6 +111,7 @@ some-other-other-name,600,2022-01-01
|
||||
}
|
||||
|
||||
func TestCheckForExistingJobs(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ type permissionInheritanceTestData struct {
|
||||
}
|
||||
|
||||
func TestGetRolesByNames(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testPermissionInheritance(t, func(t *testing.T, th *TestHelper, testData permissionInheritanceTestData) {
|
||||
actualRoles, err := th.App.GetRolesByNames([]string{testData.channelRole.Name})
|
||||
require.Nil(t, err)
|
||||
@@ -42,6 +43,7 @@ func TestGetRolesByNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRoleByName(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testPermissionInheritance(t, func(t *testing.T, th *TestHelper, testData permissionInheritanceTestData) {
|
||||
actualRole, err := th.App.GetRoleByName(context.Background(), testData.channelRole.Name)
|
||||
require.Nil(t, err)
|
||||
@@ -52,6 +54,7 @@ func TestGetRoleByName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRoleByID(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testPermissionInheritance(t, func(t *testing.T, th *TestHelper, testData permissionInheritanceTestData) {
|
||||
actualRole, err := th.App.GetRole(testData.channelRole.Id)
|
||||
require.Nil(t, err)
|
||||
@@ -62,6 +65,7 @@ func TestGetRoleByID(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAllRoles(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
testPermissionInheritance(t, func(t *testing.T, th *TestHelper, testData permissionInheritanceTestData) {
|
||||
actualRoles, err := th.App.GetAllRoles()
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProcessScheduledPosts(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
t.Run("base case - happy path", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -266,6 +267,7 @@ func TestProcessScheduledPosts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHandleFailedScheduledPosts(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -354,7 +356,7 @@ func TestHandleFailedScheduledPosts(t *testing.T) {
|
||||
// Helper function to check notifications for a specific user
|
||||
checkUserNotification := func(user *model.User) {
|
||||
// Wait time for notifications to be sent (adding 5 secs because it is run in a separate goroutine)
|
||||
var timeout = 5 * time.Second
|
||||
timeout := 5 * time.Second
|
||||
begin := time.Now()
|
||||
channel, appErr := th.App.GetOrCreateDirectChannel(rctx, user.Id, systemBot.UserId)
|
||||
assert.True(t, appErr == nil)
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSaveScheduledPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
user1ConnID := model.NewId()
|
||||
@@ -225,6 +226,7 @@ func TestSaveScheduledPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetUserTeamScheduledPosts(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
user1ConnID := model.NewId()
|
||||
@@ -459,6 +461,7 @@ func TestGetUserTeamScheduledPosts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateScheduledPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
user1ConnID := model.NewId()
|
||||
@@ -672,6 +675,7 @@ func TestUpdateScheduledPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteScheduledPost(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
user1ConnID := model.NewId()
|
||||
@@ -756,6 +760,7 @@ func TestDeleteScheduledPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPublishScheduledPostEvent(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ func newServerWithConfig(t *testing.T, f func(cfg *model.Config)) (*Server, erro
|
||||
}
|
||||
|
||||
func TestStartServerSuccess(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
})
|
||||
@@ -70,6 +71,7 @@ func TestStartServerSuccess(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartServerPortUnavailable(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// Listen on the next available port
|
||||
listener, err := net.Listen("tcp", "localhost:0")
|
||||
require.NoError(t, err)
|
||||
@@ -88,6 +90,7 @@ func TestStartServerPortUnavailable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartServerNoS3Bucket(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
s3Host := os.Getenv("CI_MINIO_HOST")
|
||||
if s3Host == "" {
|
||||
s3Host = "localhost"
|
||||
@@ -140,6 +143,7 @@ func TestStartServerNoS3Bucket(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartServerTLSSuccess(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
testDir, _ := fileutils.FindDir("tests")
|
||||
|
||||
@@ -165,6 +169,7 @@ func TestStartServerTLSSuccess(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartServerTLSVersion(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
configStore, _ := config.NewMemoryStore()
|
||||
store, _ := config.NewStoreFromBacking(configStore, nil, false)
|
||||
cfg := store.Get()
|
||||
@@ -205,7 +210,6 @@ func TestStartServerTLSVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
err = checkEndpoint(t, client, "https://localhost:"+strconv.Itoa(s.ListenAddr.Port)+"/")
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Expected nil, got %s", err)
|
||||
}
|
||||
@@ -215,6 +219,7 @@ func TestStartServerTLSVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartServerTLSOverwriteCipher(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
testDir, _ := fileutils.FindDir("tests")
|
||||
|
||||
@@ -280,6 +285,7 @@ func checkEndpoint(t *testing.T, client *http.Client, url string) error {
|
||||
}
|
||||
|
||||
func TestPanicLog(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
// Creating a temp dir for log
|
||||
tmpDir, err := os.MkdirTemp("", "mlog-test")
|
||||
require.NoError(t, err, "cannot create tmp dir for log file")
|
||||
@@ -347,8 +353,8 @@ func TestPanicLog(t *testing.T) {
|
||||
s.Shutdown()
|
||||
|
||||
// Checking whether panic was logged
|
||||
var panicLogged = false
|
||||
var infoLogged = false
|
||||
panicLogged := false
|
||||
infoLogged := false
|
||||
|
||||
logFile, err := os.Open(config.GetLogFileLocation(tmpDir))
|
||||
require.NoError(t, err, "cannot open log file")
|
||||
@@ -494,6 +500,7 @@ func TestSentry(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelTaskSetsTaskToNil(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
var taskMut sync.Mutex
|
||||
task := model.CreateRecurringTaskFromNextIntervalTime("a test task", func() {}, 5*time.Minute)
|
||||
require.NotNil(t, task)
|
||||
@@ -503,6 +510,7 @@ func TestCancelTaskSetsTaskToNil(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOriginChecker(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -98,6 +99,7 @@ func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateSessionOnPromoteDemote(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -151,10 +153,13 @@ func TestUpdateSessionOnPromoteDemote(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
const hourMillis int64 = 60 * 60 * 1000
|
||||
const dayMillis int64 = 24 * hourMillis
|
||||
const (
|
||||
hourMillis int64 = 60 * 60 * 1000
|
||||
dayMillis int64 = 24 * hourMillis
|
||||
)
|
||||
|
||||
func TestApp_GetSessionLengthInMillis(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -222,7 +227,8 @@ func TestApp_GetSessionLengthInMillis(t *testing.T) {
|
||||
UserId: model.NewId(),
|
||||
Props: map[string]string{
|
||||
model.UserAuthServiceIsSaml: "true",
|
||||
}}
|
||||
},
|
||||
}
|
||||
session, err := th.App.CreateSession(th.Context, session)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -243,6 +249,7 @@ func TestApp_GetSessionLengthInMillis(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApp_ExtendExpiryIfNeeded(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -284,7 +291,7 @@ func TestApp_ExtendExpiryIfNeeded(t *testing.T) {
|
||||
require.False(t, session.IsExpired())
|
||||
})
|
||||
|
||||
var tests = []struct {
|
||||
tests := []struct {
|
||||
enabled bool
|
||||
name string
|
||||
session *model.Session
|
||||
@@ -365,6 +372,7 @@ func TestGetCloudSession(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRemoteClusterSession(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
token := model.NewId()
|
||||
remoteID := model.NewId()
|
||||
@@ -400,6 +408,7 @@ func TestGetRemoteClusterSession(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSessionsLimit(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -447,6 +456,7 @@ func TestSessionsLimit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetExtraSessionProps(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ func setupSharedChannels(tb testing.TB) *TestHelper {
|
||||
}
|
||||
|
||||
func TestApp_CheckCanInviteToSharedChannel(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := setupSharedChannels(t).InitBasic()
|
||||
|
||||
channel1 := th.CreateChannel(th.Context, th.BasicTeam)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestProcessSlackText(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -33,6 +34,7 @@ func TestProcessSlackText(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessSlackAnnouncement(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCustomStatus(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -44,6 +45,7 @@ func TestCustomStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCustomStatusErrors(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
fakeUserID := "foobar"
|
||||
mockErr := store.NewErrNotFound("User", fakeUserID)
|
||||
mockUser := &model.User{Id: fakeUserID}
|
||||
@@ -111,6 +113,7 @@ func TestCustomStatusErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetCustomStatus(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGenerateSupportPacket(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -270,6 +271,7 @@ func TestGenerateSupportPacket(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPluginsFile(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -334,6 +336,7 @@ func TestGetPluginsFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSupportPacketStats(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
|
||||
generateStats := func(t *testing.T) *model.SupportPacketStats {
|
||||
@@ -463,6 +466,7 @@ func TestGetSupportPacketStats(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSupportPacketJobList(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -576,6 +580,7 @@ func TestGetSupportPacketJobList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSupportPacketPermissionsInfo(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -662,6 +667,7 @@ func TestGetSupportPacketPermissionsInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSupportPacketMetadata(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
|
||||
//nolint:govet // The setup code leads to a lot of variable shadowing.
|
||||
func TestCreateDefaultMemberships(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -530,6 +531,7 @@ func (us *mokeUserStore) Get(_ context.Context, id string) (*model.User, error)
|
||||
}
|
||||
|
||||
func TestDeleteGroupMemberships(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -597,6 +599,7 @@ func TestDeleteGroupMemberships(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSyncSyncableRoles(t *testing.T) {
|
||||
mainHelper.Parallel(t)
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
|
||||
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Ссылка в новой задаче
Block a user