MM-27149: optimize initBasic (#15063)
* MM-27149: optimize initBasic Mostly, all tests just needed the user initialization part and not the channel and group creation. So we move the user initialization inside the Setup call. This avoids unnecessary DB calls which take around 250-300ms on average. And we make the login requests concurrently to shave off a few more ms. According to my tests, the 2 login calls take 140 ms on average, which shaves off 70ms. So approximately, we shave off 350ms per test. And there are 114 occurences of these. So around 39 seconds. * make initlogin only for Setup/SetupEnterprise Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
30bd506e76
Коммит
4a2715974d
@@ -188,7 +188,9 @@ func SetupEnterprise(tb testing.TB) *TestHelper {
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
searchEngine := mainHelper.GetSearchEngine()
|
||||
return setupTestHelper(dbStore, searchEngine, true, true, nil)
|
||||
th := setupTestHelper(dbStore, searchEngine, true, true, nil)
|
||||
th.InitLogin()
|
||||
return th
|
||||
}
|
||||
|
||||
func Setup(tb testing.TB) *TestHelper {
|
||||
@@ -204,7 +206,9 @@ func Setup(tb testing.TB) *TestHelper {
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
searchEngine := mainHelper.GetSearchEngine()
|
||||
return setupTestHelper(dbStore, searchEngine, false, true, nil)
|
||||
th := setupTestHelper(dbStore, searchEngine, false, true, nil)
|
||||
th.InitLogin()
|
||||
return th
|
||||
}
|
||||
|
||||
func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelper {
|
||||
@@ -220,7 +224,9 @@ func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelpe
|
||||
dbStore.DropAllTables()
|
||||
dbStore.MarkSystemRanUnitTests()
|
||||
searchEngine := mainHelper.GetSearchEngine()
|
||||
return setupTestHelper(dbStore, searchEngine, false, true, updateConfig)
|
||||
th := setupTestHelper(dbStore, searchEngine, false, true, updateConfig)
|
||||
th.InitLogin()
|
||||
return th
|
||||
}
|
||||
|
||||
func SetupConfigWithStoreMock(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelper {
|
||||
@@ -283,7 +289,7 @@ var userCache struct {
|
||||
BasicUser2 *model.User
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
func (me *TestHelper) InitLogin() *TestHelper {
|
||||
me.waitForConnectivity()
|
||||
|
||||
// create users once and cache them because password hashing is slow
|
||||
@@ -318,9 +324,21 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.BasicUser.Password = "Pa$$word11"
|
||||
me.BasicUser2.Password = "Pa$$word11"
|
||||
|
||||
me.LoginSystemAdmin()
|
||||
me.LoginTeamAdmin()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
me.LoginSystemAdmin()
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
me.LoginTeamAdmin()
|
||||
wg.Done()
|
||||
}()
|
||||
wg.Wait()
|
||||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) InitBasic() *TestHelper {
|
||||
me.BasicTeam = me.CreateTeam()
|
||||
me.BasicChannel = me.CreatePublicChannel()
|
||||
me.BasicPrivateChannel = me.CreatePrivateChannel()
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBlevePurgeIndexes(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("as system user", func(t *testing.T) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
func TestCreateBot(t *testing.T) {
|
||||
t.Run("create bot without permissions", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -137,7 +137,7 @@ func TestCreateBot(t *testing.T) {
|
||||
|
||||
func TestPatchBot(t *testing.T) {
|
||||
t.Run("patch non-existent bot", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
defer th.RestoreDefaultRolePermissions(th.SaveDefaultRolePermissions())
|
||||
|
||||
@@ -204,7 +204,7 @@ func TestPatchBot(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("patch someone else's bot without permission", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
defer th.RestoreDefaultRolePermissions(th.SaveDefaultRolePermissions())
|
||||
|
||||
@@ -1278,7 +1278,7 @@ func TestSetBotIconImage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetBotIconImage(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
defer th.RestoreDefaultRolePermissions(th.SaveDefaultRolePermissions())
|
||||
@@ -1340,7 +1340,7 @@ func TestGetBotIconImage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteBotIconImage(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
defer th.RestoreDefaultRolePermissions(th.SaveDefaultRolePermissions())
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetBrandImage(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestGetBrandImage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUploadBrandImage(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestUploadBrandImage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteBrandImage(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
data, err := testutils.ReadTestFile("test.png")
|
||||
|
||||
@@ -3180,7 +3180,7 @@ func TestAutocompleteChannelsForSearchGuestUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateChannelScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetClusterStatus(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("as system user", func(t *testing.T) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetConfig(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestGetConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReloadConfig(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestReloadConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateConfig(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -179,7 +179,7 @@ func TestUpdateConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateConfigMessageExportSpecialHandling(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
messageExportEnabled := *th.App.Config().MessageExportSettings.EnableExport
|
||||
@@ -247,7 +247,7 @@ func TestUpdateConfigMessageExportSpecialHandling(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateConfigRestrictSystemAdmin(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ExperimentalSettings.RestrictSystemAdmin = true })
|
||||
|
||||
@@ -293,7 +293,7 @@ func TestGetEnvironmentConfig(t *testing.T) {
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_SITEURL")
|
||||
defer os.Unsetenv("MM_SERVICESETTINGS_ENABLECUSTOMEMOJI")
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("as system admin", func(t *testing.T) {
|
||||
@@ -350,7 +350,7 @@ func TestGetEnvironmentConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetOldClientConfig(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
testKey := "supersecretkey"
|
||||
@@ -402,7 +402,7 @@ func TestGetOldClientConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchConfig(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("config is missing", func(t *testing.T) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDataRetentionGetPolicy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.GetDataRetentionPolicy()
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestElasticsearchTest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("as system user", func(t *testing.T) {
|
||||
@@ -32,7 +32,7 @@ func TestElasticsearchTest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestElasticsearchPurgeIndexes(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("as system user", func(t *testing.T) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetGroup(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
@@ -60,7 +60,7 @@ func TestGetGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchGroup(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
@@ -408,7 +408,7 @@ func TestGetGroupChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupTeams(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
id := model.NewId()
|
||||
@@ -1073,7 +1073,7 @@ func TestGetGroupStats(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
|
||||
|
||||
@@ -65,7 +65,7 @@ func testAPIHandlerNoGzipMode(t *testing.T, name string, h http.Handler, token s
|
||||
}
|
||||
|
||||
func TestAPIHandlersWithGzip(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
api := Init(th.Server, th.Server.AppOptions, th.Server.Router)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetImage(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
// Prevent the test client from following a redirect
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateJob(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
job := &model.Job{
|
||||
@@ -39,7 +39,7 @@ func TestCreateJob(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetJob(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
job := &model.Job{
|
||||
@@ -68,7 +68,7 @@ func TestGetJob(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetJobs(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
jobType := model.NewId()
|
||||
@@ -115,7 +115,7 @@ func TestGetJobs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetJobsByType(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
jobType := model.NewId()
|
||||
@@ -173,7 +173,7 @@ func TestGetJobsByType(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCancelJob(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
jobs := []*model.Job{
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTestLdap(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
@@ -37,7 +37,7 @@ func TestTestLdap(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSyncLdap(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
@@ -59,7 +59,7 @@ func TestSyncLdap(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLdapGroups(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.GetLdapGroups()
|
||||
@@ -74,7 +74,7 @@ func TestGetLdapGroups(t *testing.T) {
|
||||
func TestLinkLdapGroup(t *testing.T) {
|
||||
const entryUUID string = "foo"
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.LinkLdapGroup(entryUUID)
|
||||
@@ -87,7 +87,7 @@ func TestLinkLdapGroup(t *testing.T) {
|
||||
func TestUnlinkLdapGroup(t *testing.T) {
|
||||
const entryUUID string = "foo"
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.UnlinkLdapGroup(entryUUID)
|
||||
@@ -98,7 +98,7 @@ func TestUnlinkLdapGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMigrateIdLdap(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.MigrateIdLdap("objectGUID")
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetOldClientLicense(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestGetOldClientLicense(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUploadLicenseFile(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
LocalClient := th.LocalClient
|
||||
@@ -78,7 +78,7 @@ func TestUploadLicenseFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveLicenseFile(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
LocalClient := th.LocalClient
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateOAuthApp(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
@@ -188,7 +188,7 @@ func TestUpdateOAuthApp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetOAuthApps(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
@@ -254,7 +254,7 @@ func TestGetOAuthApps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetOAuthApp(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
@@ -318,7 +318,7 @@ func TestGetOAuthApp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetOAuthAppInfo(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
@@ -382,7 +382,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteOAuthApp(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
@@ -449,7 +449,7 @@ func TestDeleteOAuthApp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRegenerateOAuthAppSecret(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPlugin(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
@@ -273,7 +273,7 @@ func TestPlugin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNotifyClusterPluginEvent(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
testCluster := &testlib.FakeClusterInterface{}
|
||||
@@ -384,11 +384,11 @@ func TestDisableOnRemove(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.Description, func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.Enable = true
|
||||
@@ -470,7 +470,7 @@ func TestDisableOnRemove(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetMarketplacePlugins(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -666,7 +666,7 @@ func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("marketplace client returns not-installed plugin", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
@@ -728,7 +728,7 @@ func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("marketplace client returns installed plugin", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -908,7 +908,7 @@ func TestSearchGetMarketplacePlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLocalPluginInMarketplace(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
samplePlugins := []*model.MarketplacePlugin{
|
||||
@@ -1072,7 +1072,7 @@ func TestGetLocalPluginInMarketplace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
marketplacePlugins := []*model.MarketplacePlugin{
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetRole(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
role := &model.Role{
|
||||
@@ -51,7 +51,7 @@ func TestGetRole(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRoleByName(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
role := &model.Role{
|
||||
@@ -88,7 +88,7 @@ func TestGetRoleByName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRolesByNames(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
role1 := &model.Role{
|
||||
@@ -158,7 +158,7 @@ func TestGetRolesByNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchRole(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
role := &model.Role{
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetSamlMetadata(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
@@ -472,7 +472,7 @@ func TestGetChannelsForScheme(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("custom_permissions_schemes"))
|
||||
@@ -579,7 +579,7 @@ func TestPatchScheme(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("ValidTeamScheme", func(t *testing.T) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetPing(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("basic ping", func(t *testing.T) {
|
||||
@@ -66,7 +66,7 @@ func TestGetPing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAudits(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestGetAudits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEmailTest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -148,7 +148,7 @@ func TestEmailTest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSiteURLTest(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -189,7 +189,7 @@ func TestSiteURLTest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDatabaseRecycle(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -212,7 +212,7 @@ func TestDatabaseRecycle(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInvalidateCaches(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -238,7 +238,7 @@ func TestInvalidateCaches(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLogs(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
@@ -272,7 +272,7 @@ func TestGetLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPostLog(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -381,7 +381,7 @@ func TestGetAnalyticsOld(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestS3TestConnection(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -450,7 +450,7 @@ func TestS3TestConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSupportedTimezones(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -473,7 +473,7 @@ func TestRedirectLocation(t *testing.T) {
|
||||
|
||||
mockBitlyLink := testServer.URL
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
enableLinkPreviews := *th.App.Config().ServiceSettings.EnableLinkPreviews
|
||||
@@ -518,7 +518,7 @@ func TestRedirectLocation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetServerBusy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
const secs = 30
|
||||
@@ -539,7 +539,7 @@ func TestSetServerBusy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetServerBusyInvalidParam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
|
||||
@@ -554,7 +554,7 @@ func TestSetServerBusyInvalidParam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClearServerBusy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -575,7 +575,7 @@ func TestClearServerBusy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetServerBusy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -594,7 +594,7 @@ func TestGetServerBusy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetServerBusyExpires(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -612,7 +612,7 @@ func TestGetServerBusyExpires(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServerBusy503(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().Busy.Set(time.Second * 30)
|
||||
@@ -651,7 +651,7 @@ func TestServerBusy503(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPushNotificationAck(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
api := Init(th.Server, th.Server.AppOptions, th.Server.Router)
|
||||
session, _ := th.App.GetSession(th.Client.AuthToken)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestCreateTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateTeamSanitization(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
// Non-admin users can create a team, but they become a team admin by doing so
|
||||
@@ -253,7 +253,7 @@ func TestGetTeamUnread(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.TestForAllClients(t, func(t *testing.T, client *model.Client4) {
|
||||
@@ -351,7 +351,7 @@ func TestUpdateTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTeamSanitization(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
@@ -470,7 +470,7 @@ func TestPatchTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRestoreTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -539,7 +539,7 @@ func TestRestoreTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPatchTeamSanitization(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
@@ -571,7 +571,7 @@ func TestPatchTeamSanitization(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTeamPrivacy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -648,7 +648,7 @@ func TestUpdateTeamPrivacy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTeamUnicodeNames(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -715,7 +715,7 @@ func TestTeamUnicodeNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRegenerateTeamInviteId(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -770,7 +770,7 @@ func TestSoftDeleteTeam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPermanentDeleteTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
enableAPITeamDeletion := *th.App.Config().ServiceSettings.EnableAPITeamDeletion
|
||||
@@ -987,7 +987,7 @@ func TestGetAllTeams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAllTeamsSanitization(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
team, resp := th.Client.CreateTeam(&model.Team{
|
||||
@@ -1210,7 +1210,7 @@ func TestSearchAllTeams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchAllTeamsPaged(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
commonRandom := model.NewId()
|
||||
teams := [3]*model.Team{}
|
||||
@@ -3044,7 +3044,7 @@ func TestRemoveTeamIcon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTeamScheme(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateUser(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||
@@ -80,7 +80,7 @@ func TestCreateUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateUserInputFilter(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("DomainRestriction", func(t *testing.T) {
|
||||
@@ -580,7 +580,7 @@ func TestGetMe(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetUser(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
user := th.CreateUser()
|
||||
@@ -630,7 +630,7 @@ func TestGetUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetUserWithAcceptedTermsOfServiceForOtherUser(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
user := th.CreateUser()
|
||||
@@ -829,7 +829,7 @@ func TestGetUserByUsernameWithAcceptedTermsOfService(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetUserByEmail(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
user := th.CreateUser()
|
||||
@@ -1477,7 +1477,7 @@ func TestGetUsersByIds(t *testing.T) {
|
||||
|
||||
func TestGetUsersByIdsWithOptions(t *testing.T) {
|
||||
t.Run("should only return specified users that have been updated since the given time", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
// Users before the timestamp shouldn't be returned
|
||||
@@ -1559,7 +1559,7 @@ func TestGetUsersByUsernames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetTotalUsersStat(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
total, _ := th.Server.Store.User().Count(model.UserCountOptions{
|
||||
@@ -1574,7 +1574,7 @@ func TestGetTotalUsersStat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateUser(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
user := th.CreateUser()
|
||||
@@ -1737,7 +1737,7 @@ func TestPatchUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserUnicodeNames(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -1800,7 +1800,7 @@ func TestUserUnicodeNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateUserAuth(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
team := th.CreateTeamWithClient(th.SystemAdminClient)
|
||||
@@ -2167,7 +2167,7 @@ func TestUpdateUserActive(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetUsers(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
rusers, resp := th.Client.GetUsers(0, 60, "")
|
||||
@@ -3060,7 +3060,7 @@ func TestGetUserAudits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVerifyUserEmail(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
email := th.GenerateTestEmail()
|
||||
@@ -4491,7 +4491,7 @@ func TestUserAccessTokenDisableConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserAccessTokenDisableConfigBotsExcluded(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -4872,7 +4872,7 @@ func TestPromoteGuestToUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVerifyUserEmailWithoutToken(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("Should verify a new user", func(t *testing.T) {
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestWebSocket(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWebSocketTrailingSlash(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
url := fmt.Sprintf("ws://localhost:%v", th.App.Srv().ListenAddr.Port)
|
||||
@@ -196,7 +196,7 @@ func TestCreateDirectChannelWithSocket(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWebsocketOriginSecurity(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
url := fmt.Sprintf("ws://localhost:%v", th.App.Srv().ListenAddr.Port)
|
||||
|
||||
Ссылка в новой задаче
Block a user