[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
Этот коммит содержится в:
Claudio Costa
2025-05-30 05:58:26 -06:00
коммит произвёл GitHub
родитель 1cf2f08108
Коммит 611b2a8e79
191 изменённых файлов: 2719 добавлений и 496 удалений

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

@@ -41,6 +41,7 @@ type TestHelper struct {
App *app.App
Server *app.Server
ConfigStore *config.Store
Store store.Store
Context *request.Context
Client *model.Client4
@@ -69,8 +70,6 @@ type TestHelper struct {
LogBuffer *mlog.Buffer
TestLogger *mlog.Logger
workspace string
}
var mainHelper *testlib.MainHelper
@@ -79,7 +78,7 @@ func SetMainHelper(mh *testlib.MainHelper) {
mainHelper = mh
}
func setupTestHelper(tb testing.TB, dbStore store.Store, searchEngine *searchengine.Broker, enterprise bool, includeCache bool,
func setupTestHelper(tb testing.TB, dbStore store.Store, sqlSettings *model.SqlSettings, searchEngine *searchengine.Broker, enterprise bool, includeCache bool,
updateConfig func(*model.Config), options []app.Option,
) *TestHelper {
tempWorkspace, err := os.MkdirTemp("", "apptest")
@@ -89,9 +88,11 @@ func setupTestHelper(tb testing.TB, dbStore store.Store, searchEngine *searcheng
require.NoError(tb, err, "failed to initialize memory store")
memoryConfig := &model.Config{
SqlSettings: *mainHelper.GetSQLSettings(),
SqlSettings: model.SafeDereference(sqlSettings),
}
memoryConfig.SetDefaults()
*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.FileSettings.Directory = filepath.Join(tempWorkspace, "data")
@@ -99,11 +100,12 @@ func setupTestHelper(tb testing.TB, dbStore store.Store, searchEngine *searcheng
*memoryConfig.ServiceSettings.LocalModeSocketLocation = filepath.Join(tempWorkspace, "mattermost_local.sock")
*memoryConfig.LogSettings.EnableSentry = false // disable error reporting during tests
*memoryConfig.LogSettings.ConsoleLevel = mlog.LvlStdLog.Name
*memoryConfig.LogSettings.FileLocation = filepath.Join(tempWorkspace, "logs", "mattermost.log")
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
// Enabling Redis with Postgres.
if *memoryConfig.SqlSettings.DriverName == model.DatabaseDriverPostgres {
if *memoryConfig.SqlSettings.DriverName == model.DatabaseDriverPostgres && !mainHelper.Options.RunParallel {
*memoryConfig.CacheSettings.CacheType = model.CacheTypeRedis
redisHost := "localhost"
if os.Getenv("IS_CI") == "true" {
@@ -156,7 +158,7 @@ func setupTestHelper(tb testing.TB, dbStore store.Store, searchEngine *searcheng
IncludeCacheLayer: includeCache,
TestLogger: testLogger,
LogBuffer: buffer,
workspace: tempWorkspace,
Store: dbStore,
}
if s.Platform().SearchEngine != nil && s.Platform().SearchEngine.BleveEngine != nil && searchEngine != nil {
@@ -190,6 +192,14 @@ func setupTestHelper(tb testing.TB, dbStore store.Store, searchEngine *searcheng
*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)
}
err = th.Server.Start()
require.NoError(tb, err)
@@ -203,7 +213,6 @@ func setupTestHelper(tb testing.TB, dbStore store.Store, searchEngine *searcheng
th.SystemManagerClient = th.CreateClient()
// Verify handling of the supported true/false values by randomizing on each run.
rand.Seed(time.Now().UTC().UnixNano())
trueValues := []string{"1", "t", "T", "TRUE", "true", "True"}
falseValues := []string{"0", "f", "F", "FALSE", "false", "False"}
trueString := trueValues[rand.Intn(len(trueValues))]
@@ -231,6 +240,27 @@ func getLicense(enterprise bool, cfg *model.Config) *model.License {
return nil
}
func setupStores(tb testing.TB) (store.Store, *model.SqlSettings, *searchengine.Broker) {
var dbStore store.Store
var dbSettings *model.SqlSettings
var searchEngine *searchengine.Broker
if mainHelper.Options.RunParallel {
dbStore, _, 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.Settings
}
return dbStore, dbSettings, searchEngine
}
func SetupEnterprise(tb testing.TB, options ...app.Option) *TestHelper {
if testing.Short() {
tb.SkipNow()
@@ -240,13 +270,10 @@ func SetupEnterprise(tb testing.TB, options ...app.Option) *TestHelper {
tb.SkipNow()
}
dbStore := mainHelper.GetStore()
dbStore.DropAllTables()
dbStore.MarkSystemRanUnitTests()
mainHelper.PreloadMigrations()
searchEngine := mainHelper.GetSearchEngine()
th := setupTestHelper(tb, dbStore, searchEngine, true, true, nil, options)
dbStore, dbSettings, searchEngine := setupStores(tb)
th := setupTestHelper(tb, dbStore, dbSettings, searchEngine, true, true, nil, options)
th.InitLogin(tb)
return th
}
@@ -259,13 +286,10 @@ func Setup(tb testing.TB) *TestHelper {
tb.SkipNow()
}
dbStore := mainHelper.GetStore()
dbStore.DropAllTables()
dbStore.MarkSystemRanUnitTests()
mainHelper.PreloadMigrations()
searchEngine := mainHelper.GetSearchEngine()
th := setupTestHelper(tb, dbStore, searchEngine, false, true, nil, nil)
dbStore, dbSettings, searchEngine := setupStores(tb)
th := setupTestHelper(tb, dbStore, dbSettings, searchEngine, false, true, nil, nil)
th.InitLogin(tb)
return th
}
@@ -278,14 +302,11 @@ func SetupAndApplyConfigBeforeLogin(tb testing.TB, updateConfig func(cfg *model.
tb.SkipNow()
}
dbStore := mainHelper.GetStore()
dbStore.DropAllTables()
dbStore.MarkSystemRanUnitTests()
mainHelper.PreloadMigrations()
searchEngine := mainHelper.GetSearchEngine()
th := setupTestHelper(tb, dbStore, searchEngine, false, true, nil, nil)
dbStore, dbSettings, searchEngine := setupStores(tb)
th := setupTestHelper(tb, dbStore, dbSettings, searchEngine, false, true, nil, nil)
th.App.UpdateConfig(updateConfig)
th.InitLogin(tb)
return th
}
@@ -298,18 +319,15 @@ func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelpe
tb.SkipNow()
}
dbStore := mainHelper.GetStore()
dbStore.DropAllTables()
dbStore.MarkSystemRanUnitTests()
mainHelper.PreloadMigrations()
searchEngine := mainHelper.GetSearchEngine()
th := setupTestHelper(tb, dbStore, searchEngine, false, true, updateConfig, nil)
dbStore, dbSettings, searchEngine := setupStores(tb)
th := setupTestHelper(tb, dbStore, dbSettings, searchEngine, false, true, updateConfig, nil)
th.InitLogin(tb)
return th
}
func SetupConfigWithStoreMock(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelper {
th := setupTestHelper(tb, testlib.GetMockStoreForSetupFunctions(), nil, false, false, updateConfig, nil)
th := setupTestHelper(tb, testlib.GetMockStoreForSetupFunctions(), nil, nil, false, false, updateConfig, nil)
statusMock := mocks.StatusStore{}
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
@@ -323,7 +341,7 @@ func SetupConfigWithStoreMock(tb testing.TB, updateConfig func(cfg *model.Config
}
func SetupWithStoreMock(tb testing.TB) *TestHelper {
th := setupTestHelper(tb, testlib.GetMockStoreForSetupFunctions(), nil, false, false, nil, nil)
th := setupTestHelper(tb, testlib.GetMockStoreForSetupFunctions(), nil, nil, false, false, nil, nil)
statusMock := mocks.StatusStore{}
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
@@ -337,7 +355,7 @@ func SetupWithStoreMock(tb testing.TB) *TestHelper {
}
func SetupEnterpriseWithStoreMock(tb testing.TB, options ...app.Option) *TestHelper {
th := setupTestHelper(tb, testlib.GetMockStoreForSetupFunctions(), nil, true, false, nil, options)
th := setupTestHelper(tb, testlib.GetMockStoreForSetupFunctions(), nil, nil, true, false, nil, options)
statusMock := mocks.StatusStore{}
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
@@ -359,13 +377,10 @@ func SetupWithServerOptions(tb testing.TB, options []app.Option) *TestHelper {
tb.SkipNow()
}
dbStore := mainHelper.GetStore()
dbStore.DropAllTables()
dbStore.MarkSystemRanUnitTests()
mainHelper.PreloadMigrations()
searchEngine := mainHelper.GetSearchEngine()
th := setupTestHelper(tb, dbStore, searchEngine, false, true, nil, options)
dbStore, dbSettings, searchEngine := setupStores(tb)
th := setupTestHelper(tb, dbStore, dbSettings, searchEngine, false, true, nil, options)
th.InitLogin(tb)
return th
}
@@ -378,13 +393,10 @@ func SetupEnterpriseWithServerOptions(tb testing.TB, options []app.Option) *Test
tb.SkipNow()
}
dbStore := mainHelper.GetStore()
dbStore.DropAllTables()
dbStore.MarkSystemRanUnitTests()
mainHelper.PreloadMigrations()
searchEngine := mainHelper.GetSearchEngine()
th := setupTestHelper(tb, dbStore, searchEngine, true, true, nil, options)
dbStore, dbSettings, searchEngine := setupStores(tb)
th := setupTestHelper(tb, dbStore, dbSettings, searchEngine, true, true, nil, options)
th.InitLogin(tb)
return th
}
@@ -413,8 +425,8 @@ func (th *TestHelper) TearDown() {
th.ShutdownApp()
// Cleanup the workspace
if th.workspace != "" {
err := os.RemoveAll(th.workspace)
if th.tempWorkspace != "" {
err := os.RemoveAll(th.tempWorkspace)
if err != nil {
panic(err)
}
@@ -444,29 +456,48 @@ func (th *TestHelper) InitLogin(tb testing.TB) *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.SystemManagerUser = th.CreateUser()
th.App.UpdateUserRoles(th.Context, th.SystemManagerUser.Id, model.SystemUserRoleId+" "+model.SystemManagerRoleId, false)
th.SystemManagerUser, _ = th.App.GetUser(th.SystemManagerUser.Id)
th.SystemManagerUser, err = th.App.GetUser(th.SystemManagerUser.Id)
if err != nil {
panic(err)
}
userCache.SystemManagerUser = th.SystemManagerUser.DeepCopy()
th.TeamAdminUser = th.CreateUser()
th.App.UpdateUserRoles(th.Context, th.TeamAdminUser.Id, model.SystemUserRoleId, false)
th.TeamAdminUser, _ = th.App.GetUser(th.TeamAdminUser.Id)
th.TeamAdminUser, err = th.App.GetUser(th.TeamAdminUser.Id)
if err != nil {
panic(err)
}
userCache.TeamAdminUser = th.TeamAdminUser.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.SystemManagerUser = userCache.SystemManagerUser.DeepCopy()
@@ -474,8 +505,7 @@ func (th *TestHelper) InitLogin(tb testing.TB) *TestHelper {
th.BasicUser = userCache.BasicUser.DeepCopy()
th.BasicUser2 = userCache.BasicUser2.DeepCopy()
users := []*model.User{th.SystemAdminUser, th.TeamAdminUser, th.BasicUser, th.BasicUser2, th.SystemManagerUser}
mainHelper.GetSQLStore().User().InsertUsers(users)
th.Store.User().InsertUsers([]*model.User{th.SystemAdminUser, th.TeamAdminUser, th.BasicUser, th.BasicUser2, th.SystemManagerUser})
// restore non hashed password for login
th.SystemAdminUser.Password = "Pa$$word11"
@@ -494,7 +524,9 @@ func (th *TestHelper) InitLogin(tb testing.TB) *TestHelper {
th.LoginTeamAdmin()
wg.Done()
}()
wg.Wait()
return th
}
@@ -1418,3 +1450,7 @@ func (th *TestHelper) SetupScheme(scope string) *model.Scheme {
}
return scheme
}
func (th *TestHelper) Parallel(t *testing.T) {
mainHelper.Parallel(t)
}

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

@@ -13,6 +13,7 @@ import (
)
func TestBlevePurgeIndexes(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -17,6 +17,7 @@ import (
)
func TestCreateBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("create bot without permissions", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -168,6 +169,7 @@ func TestCreateBot(t *testing.T) {
}
func TestPatchBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("patch non-existent bot", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -591,6 +593,7 @@ func TestPatchBot(t *testing.T) {
}
func TestGetBot(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -772,6 +775,7 @@ func TestGetBot(t *testing.T) {
}
func TestGetBots(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic().DeleteBots()
defer th.TearDown()
@@ -1080,6 +1084,7 @@ func TestGetBots(t *testing.T) {
}
func TestDisableBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("disable non-existent bot", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1199,7 +1204,9 @@ func TestDisableBot(t *testing.T) {
})
})
}
func TestEnableBot(t *testing.T) {
mainHelper.Parallel(t)
t.Run("enable non-existent bot", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1333,6 +1340,7 @@ func TestEnableBot(t *testing.T) {
}
func TestAssignBot(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1513,6 +1521,7 @@ func TestAssignBot(t *testing.T) {
}
func TestConvertBotToUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -15,6 +15,7 @@ import (
)
func TestGetBrandImage(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -35,6 +36,7 @@ func TestGetBrandImage(t *testing.T) {
}
func TestUploadBrandImage(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -136,6 +138,7 @@ func TestUploadBrandImageTwice(t *testing.T) {
}
func TestDeleteBrandImage(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -7,7 +7,6 @@ import (
"context"
"encoding/json"
"net/http"
"os"
"testing"
"time"
@@ -16,9 +15,7 @@ import (
)
func TestCreateChannelBookmark(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_ChannelBookmarks", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_ChannelBookmarks")
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
err := th.App.SetPhase2PermissionsMigrationStatus(true)
@@ -280,9 +277,7 @@ func TestCreateChannelBookmark(t *testing.T) {
}
func TestEditChannelBookmark(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_ChannelBookmarks", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_ChannelBookmarks")
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
err := th.App.SetPhase2PermissionsMigrationStatus(true)
@@ -690,9 +685,7 @@ func TestEditChannelBookmark(t *testing.T) {
}
func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_ChannelBookmarks", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_ChannelBookmarks")
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
err := th.App.SetPhase2PermissionsMigrationStatus(true)
@@ -1102,9 +1095,7 @@ func TestUpdateChannelBookmarkSortOrder(t *testing.T) {
}
func TestDeleteChannelBookmark(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_ChannelBookmarks", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_ChannelBookmarks")
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
err := th.App.SetPhase2PermissionsMigrationStatus(true)
@@ -1461,9 +1452,7 @@ func TestDeleteChannelBookmark(t *testing.T) {
}
func TestListChannelBookmarksForChannel(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_ChannelBookmarks", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_ChannelBookmarks")
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
err := th.App.SetPhase2PermissionsMigrationStatus(true)

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

@@ -18,6 +18,7 @@ import (
)
func TestCreateCategoryForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -164,6 +165,7 @@ func TestCreateCategoryForTeamForUser(t *testing.T) {
}
func TestUpdateCategoryForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -451,6 +453,7 @@ func TestUpdateCategoryForTeamForUser(t *testing.T) {
}
func TestUpdateCategoriesForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -548,6 +551,7 @@ func TestUpdateCategoriesForTeamForUser(t *testing.T) {
}
func TestGetCategoriesForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -600,6 +604,7 @@ func TestGetCategoriesForTeamForUser(t *testing.T) {
}
func TestGetCategoryOrderForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -658,6 +663,7 @@ func TestGetCategoryOrderForTeamForUser(t *testing.T) {
}
func TestUpdateCategoryOrderForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -776,6 +782,7 @@ func TestUpdateCategoryOrderForTeamForUser(t *testing.T) {
}
func TestGetCategoryForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -874,6 +881,7 @@ func TestGetCategoryForTeamForUser(t *testing.T) {
}
func TestValidateSidebarCategory(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -996,6 +1004,7 @@ func TestValidateSidebarCategory(t *testing.T) {
}
func TestValidateSidebarCategoryChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1081,6 +1090,7 @@ func TestValidateSidebarCategoryChannels(t *testing.T) {
}
func TestDeleteCategoryForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
t.Run("should move channels to default categories when custom category is deleted", func(t *testing.T) {

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

@@ -27,6 +27,7 @@ import (
)
func TestCreateChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -203,6 +204,7 @@ func TestCreateChannel(t *testing.T) {
}
func TestUpdateChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -378,6 +380,7 @@ func TestUpdateChannel(t *testing.T) {
}
func TestPatchChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1164,6 +1167,7 @@ func TestCanEditChannelBanner(t *testing.T) {
}
func TestChannelUnicodeNames(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1223,6 +1227,7 @@ func TestChannelUnicodeNames(t *testing.T) {
}
func TestCreateDirectChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1285,6 +1290,7 @@ func TestCreateDirectChannel(t *testing.T) {
}
func TestCreateDirectChannelAsGuest(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1333,6 +1339,7 @@ func TestCreateDirectChannelAsGuest(t *testing.T) {
}
func TestDeleteDirectChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1349,6 +1356,7 @@ func TestDeleteDirectChannel(t *testing.T) {
}
func TestCreateGroupChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1411,6 +1419,7 @@ func TestCreateGroupChannel(t *testing.T) {
}
func TestCreateGroupChannelAsGuest(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1478,6 +1487,7 @@ func TestCreateGroupChannelAsGuest(t *testing.T) {
}
func TestDeleteGroupChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
user := th.BasicUser
@@ -1497,6 +1507,7 @@ func TestDeleteGroupChannel(t *testing.T) {
}
func TestGetChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1547,6 +1558,7 @@ func TestGetChannel(t *testing.T) {
}
func TestGetDeletedChannelsForTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1622,6 +1634,7 @@ func TestGetDeletedChannelsForTeam(t *testing.T) {
}
func TestGetPrivateChannelsForTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
team := th.BasicTeam
@@ -1660,6 +1673,7 @@ func TestGetPrivateChannelsForTeam(t *testing.T) {
}
func TestGetPublicChannelsForTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1736,6 +1750,7 @@ func TestGetPublicChannelsForTeam(t *testing.T) {
}
func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1793,6 +1808,7 @@ func TestGetPublicChannelsByIdsForTeam(t *testing.T) {
}
func TestGetChannelsForTeamForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1873,6 +1889,7 @@ func TestGetChannelsForTeamForUser(t *testing.T) {
}
func TestGetChannelsForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1925,6 +1942,7 @@ func TestGetChannelsForUser(t *testing.T) {
}
func TestGetAllChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
th.LoginSystemManager()
defer th.TearDown()
@@ -2086,6 +2104,7 @@ func TestGetAllChannels(t *testing.T) {
}
func TestGetAllChannelsWithCount(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2118,6 +2137,7 @@ func TestGetAllChannelsWithCount(t *testing.T) {
}
func TestSearchChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2251,6 +2271,7 @@ func TestSearchChannels(t *testing.T) {
}
func TestSearchArchivedChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2341,6 +2362,7 @@ func TestSearchArchivedChannels(t *testing.T) {
}
func TestSearchAllChannels(t *testing.T) {
mainHelper.Parallel(t)
th := setupForSharedChannels(t).InitBasic()
th.LoginSystemManager()
defer th.TearDown()
@@ -2631,6 +2653,7 @@ func TestSearchAllChannels(t *testing.T) {
}
func TestSearchAllChannelsPaged(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2650,6 +2673,7 @@ func TestSearchAllChannelsPaged(t *testing.T) {
}
func TestSearchGroupChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2718,6 +2742,7 @@ func TestSearchGroupChannels(t *testing.T) {
}
func TestDeleteChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
c := th.Client
@@ -2806,6 +2831,7 @@ func TestDeleteChannel(t *testing.T) {
}
func TestDeleteChannel2(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2885,6 +2911,7 @@ func TestDeleteChannel2(t *testing.T) {
}
func TestPermanentDeleteChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2923,6 +2950,7 @@ func TestPermanentDeleteChannel(t *testing.T) {
}
func TestUpdateChannelPrivacy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3017,6 +3045,7 @@ func TestUpdateChannelPrivacy(t *testing.T) {
}
func TestRestoreChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3075,6 +3104,7 @@ func TestRestoreChannel(t *testing.T) {
}
func TestGetChannelByName(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3140,6 +3170,7 @@ func TestGetChannelByName(t *testing.T) {
}
func TestGetChannelByNameForTeamName(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3201,6 +3232,7 @@ func TestGetChannelByNameForTeamName(t *testing.T) {
}
func TestGetChannelMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.TestForAllClients(t, func(t *testing.T, client *model.Client4) {
@@ -3249,6 +3281,7 @@ func TestGetChannelMembers(t *testing.T) {
}
func TestGetChannelMembersByIds(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3291,6 +3324,7 @@ func TestGetChannelMembersByIds(t *testing.T) {
}
func TestGetChannelMember(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
c := th.Client
@@ -3340,6 +3374,7 @@ func TestGetChannelMember(t *testing.T) {
}
func TestGetChannelMembersForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3388,6 +3423,7 @@ func TestGetChannelMembersForUser(t *testing.T) {
}
func TestViewChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3466,6 +3502,7 @@ func TestViewChannel(t *testing.T) {
}
func TestReadMultipleChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3545,6 +3582,7 @@ func TestReadMultipleChannels(t *testing.T) {
}
func TestGetChannelUnread(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3593,6 +3631,7 @@ func TestGetChannelUnread(t *testing.T) {
}
func TestGetChannelStats(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3651,6 +3690,7 @@ func TestGetChannelStats(t *testing.T) {
}
func TestGetPinnedPosts(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3687,6 +3727,7 @@ func TestGetPinnedPosts(t *testing.T) {
}
func TestUpdateChannelRoles(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3766,6 +3807,7 @@ func TestUpdateChannelRoles(t *testing.T) {
}
func TestUpdateChannelMemberSchemeRoles(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3920,6 +3962,7 @@ func TestUpdateChannelMemberSchemeRoles(t *testing.T) {
}
func TestUpdateChannelNotifyProps(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3965,6 +4008,7 @@ func TestUpdateChannelNotifyProps(t *testing.T) {
}
func TestAddChannelMember(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4183,6 +4227,7 @@ func TestAddChannelMember(t *testing.T) {
}
func TestAddChannelMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4213,6 +4258,7 @@ func TestAddChannelMembers(t *testing.T) {
}
func TestAddChannelMemberFromThread(t *testing.T) {
mainHelper.Parallel(t)
t.Skip("MM-41285")
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -4334,6 +4380,7 @@ func TestAddChannelMemberGuestAccessControl(t *testing.T) {
}
func TestAddChannelMemberAddMyself(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4409,6 +4456,7 @@ func TestAddChannelMemberAddMyself(t *testing.T) {
}
func TestRemoveChannelMember(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
user1 := th.BasicUser
user2 := th.BasicUser2
@@ -4629,6 +4677,7 @@ func TestRemoveChannelMember(t *testing.T) {
}
func TestAutocompleteChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -4697,6 +4746,7 @@ func TestAutocompleteChannels(t *testing.T) {
}
func TestAutocompleteChannelsForSearch(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -4810,6 +4860,7 @@ func TestAutocompleteChannelsForSearch(t *testing.T) {
}
func TestAutocompleteChannelsForSearchGuestUsers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -4939,6 +4990,7 @@ func TestAutocompleteChannelsForSearchGuestUsers(t *testing.T) {
}
func TestUpdateChannelScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -5022,6 +5074,7 @@ func TestUpdateChannelScheme(t *testing.T) {
}
func TestGetChannelMembersTimezones(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -5065,6 +5118,7 @@ func TestGetChannelMembersTimezones(t *testing.T) {
}
func TestChannelMembersMinusGroupMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5159,6 +5213,7 @@ func TestChannelMembersMinusGroupMembers(t *testing.T) {
}
func TestGetChannelModerations(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5373,6 +5428,7 @@ func TestGetChannelModerations(t *testing.T) {
}
func TestPatchChannelModerations(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5557,6 +5613,7 @@ func TestPatchChannelModerations(t *testing.T) {
}
func TestGetChannelMemberCountsByGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5649,6 +5706,7 @@ func TestGetChannelMemberCountsByGroup(t *testing.T) {
}
func TestGetChannelsMemberCount(t *testing.T) {
mainHelper.Parallel(t)
// Setup
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5733,6 +5791,7 @@ func TestGetChannelsMemberCount(t *testing.T) {
}
func TestMoveChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5864,6 +5923,7 @@ func TestMoveChannel(t *testing.T) {
}
func TestRootMentionsCount(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5905,6 +5965,7 @@ func TestRootMentionsCount(t *testing.T) {
}
func TestViewChannelWithoutCollapsedThreads(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -17,6 +17,7 @@ import (
)
func Test_GetSubscription(t *testing.T) {
mainHelper.Parallel(t)
deliquencySince := int64(2000000000)
subscription := &model.Subscription{
@@ -52,6 +53,7 @@ func Test_GetSubscription(t *testing.T) {
}
t.Run("NON Admin users receive the user facing subscription", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -77,6 +79,7 @@ func Test_GetSubscription(t *testing.T) {
})
t.Run("Admin users receive the full subscription information", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -103,7 +106,9 @@ func Test_GetSubscription(t *testing.T) {
}
func Test_validateBusinessEmail(t *testing.T) {
mainHelper.Parallel(t)
t.Run("Returns forbidden for invalid business email", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -129,6 +134,7 @@ func Test_validateBusinessEmail(t *testing.T) {
})
t.Run("Validate business email for admin", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -154,6 +160,7 @@ func Test_validateBusinessEmail(t *testing.T) {
})
t.Run("Empty body returns bad request", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -169,7 +176,9 @@ func Test_validateBusinessEmail(t *testing.T) {
}
func Test_validateWorkspaceBusinessEmail(t *testing.T) {
mainHelper.Parallel(t)
t.Run("validate the Cloud Customer has used a valid email to create the workspace", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -201,6 +210,7 @@ func Test_validateWorkspaceBusinessEmail(t *testing.T) {
})
t.Run("validate the Cloud Customer has used a invalid email to create the workspace and must validate admin email", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -237,6 +247,7 @@ func Test_validateWorkspaceBusinessEmail(t *testing.T) {
})
t.Run("Error while grabbing the cloud customer returns bad request", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -271,6 +282,7 @@ func Test_validateWorkspaceBusinessEmail(t *testing.T) {
}
func TestGetCloudProducts(t *testing.T) {
mainHelper.Parallel(t)
cloudProducts := []*model.Product{
{
ID: "prod_test1",
@@ -337,6 +349,7 @@ func TestGetCloudProducts(t *testing.T) {
},
}
t.Run("get products for admins", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -359,6 +372,7 @@ func TestGetCloudProducts(t *testing.T) {
})
t.Run("get products for non admins", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -418,6 +432,7 @@ func TestGetCloudProducts(t *testing.T) {
}
func TestGetSelfHostedProducts(t *testing.T) {
mainHelper.Parallel(t)
products := []*model.Product{
{
ID: "prod_test",
@@ -459,6 +474,7 @@ func TestGetSelfHostedProducts(t *testing.T) {
}
t.Run("get products for admins", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -479,6 +495,7 @@ func TestGetSelfHostedProducts(t *testing.T) {
})
t.Run("get products for non admins", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -13,6 +13,7 @@ import (
)
func TestGetClusterStatus(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -14,6 +14,7 @@ import (
)
func TestHelpCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -20,6 +20,7 @@ import (
)
func TestCreateCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -36,7 +37,8 @@ func TestCreateCommand(t *testing.T) {
TeamId: th.BasicTeam.Id,
URL: "http://nowhere.com",
Method: model.CommandMethodPost,
Trigger: "trigger"}
Trigger: "trigger",
}
_, resp, err := client.CreateCommand(context.Background(), newCmd)
require.Error(t, err)
@@ -82,6 +84,7 @@ func TestCreateCommand(t *testing.T) {
}
func TestUpdateCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
user := th.SystemAdminUser
@@ -161,6 +164,7 @@ func TestUpdateCommand(t *testing.T) {
}
func TestMoveCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
user := th.SystemAdminUser
@@ -219,6 +223,7 @@ func TestMoveCommand(t *testing.T) {
}
func TestDeleteCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
user := th.SystemAdminUser
@@ -277,6 +282,7 @@ func TestDeleteCommand(t *testing.T) {
}
func TestListCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -292,7 +298,8 @@ func TestListCommands(t *testing.T) {
TeamId: th.BasicTeam.Id,
URL: "http://nowhere.com",
Method: model.CommandMethodPost,
Trigger: "custom_command"}
Trigger: "custom_command",
}
_, _, err := th.SystemAdminClient.CreateCommand(context.Background(), newCmd)
require.NoError(t, err)
@@ -372,6 +379,7 @@ func TestListCommands(t *testing.T) {
}
func TestListAutocompleteCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -381,7 +389,8 @@ func TestListAutocompleteCommands(t *testing.T) {
TeamId: th.BasicTeam.Id,
URL: "http://nowhere.com",
Method: model.CommandMethodPost,
Trigger: "custom_command"}
Trigger: "custom_command",
}
_, _, err := th.SystemAdminClient.CreateCommand(context.Background(), newCmd)
require.NoError(t, err)
@@ -441,6 +450,7 @@ func TestListAutocompleteCommands(t *testing.T) {
}
func TestListCommandAutocompleteSuggestions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -450,7 +460,8 @@ func TestListCommandAutocompleteSuggestions(t *testing.T) {
TeamId: th.BasicTeam.Id,
URL: "http://nowhere.com",
Method: model.CommandMethodPost,
Trigger: "custom_command"}
Trigger: "custom_command",
}
_, _, err := th.SystemAdminClient.CreateCommand(context.Background(), newCmd)
require.NoError(t, err)
@@ -533,6 +544,7 @@ func TestListCommandAutocompleteSuggestions(t *testing.T) {
}
func TestGetCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -547,7 +559,8 @@ func TestGetCommand(t *testing.T) {
TeamId: th.BasicTeam.Id,
URL: "http://nowhere.com",
Method: model.CommandMethodPost,
Trigger: "roger"}
Trigger: "roger",
}
newCmd, _, err := th.SystemAdminClient.CreateCommand(context.Background(), newCmd)
require.NoError(t, err)
@@ -594,6 +607,7 @@ func TestGetCommand(t *testing.T) {
}
func TestRegenToken(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -609,7 +623,8 @@ func TestRegenToken(t *testing.T) {
TeamId: th.BasicTeam.Id,
URL: "http://nowhere.com",
Method: model.CommandMethodPost,
Trigger: "trigger"}
Trigger: "trigger",
}
createdCmd, resp, err := th.SystemAdminClient.CreateCommand(context.Background(), newCmd)
require.NoError(t, err)
@@ -626,6 +641,7 @@ func TestRegenToken(t *testing.T) {
}
func TestExecuteInvalidCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -696,6 +712,7 @@ func TestExecuteInvalidCommand(t *testing.T) {
}
func TestExecuteGetCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -758,6 +775,7 @@ func TestExecuteGetCommand(t *testing.T) {
}
func TestExecutePostCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -818,6 +836,7 @@ func TestExecutePostCommand(t *testing.T) {
}
func TestExecuteCommandAgainstChannelOnAnotherTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -871,6 +890,7 @@ func TestExecuteCommandAgainstChannelOnAnotherTeam(t *testing.T) {
}
func TestExecuteCommandAgainstChannelUserIsNotIn(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -927,6 +947,7 @@ func TestExecuteCommandAgainstChannelUserIsNotIn(t *testing.T) {
}
func TestExecuteCommandInDirectMessageChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -991,6 +1012,7 @@ func TestExecuteCommandInDirectMessageChannel(t *testing.T) {
}
func TestExecuteCommandInTeamUserIsNotOn(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1067,6 +1089,7 @@ func TestExecuteCommandInTeamUserIsNotOn(t *testing.T) {
}
func TestExecuteCommandReadOnly(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client

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

@@ -17,6 +17,7 @@ import (
)
func TestEchoCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -41,6 +42,7 @@ func TestEchoCommand(t *testing.T) {
}
func TestGroupmsgCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -89,6 +91,7 @@ func TestGroupmsgCommands(t *testing.T) {
}
func TestInvitePeopleCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -167,10 +170,12 @@ func testJoinCommands(t *testing.T, alias string) {
}
func TestJoinCommands(t *testing.T) {
mainHelper.Parallel(t)
testJoinCommands(t, "join")
}
func TestLoadTestHelpCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -190,6 +195,7 @@ func TestLoadTestHelpCommands(t *testing.T) {
}
func TestLoadTestSetupCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -209,6 +215,7 @@ func TestLoadTestSetupCommands(t *testing.T) {
}
func TestLoadTestUsersCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -228,6 +235,7 @@ func TestLoadTestUsersCommands(t *testing.T) {
}
func TestLoadTestChannelsCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -247,6 +255,7 @@ func TestLoadTestChannelsCommands(t *testing.T) {
}
func TestLoadTestPostsCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -266,6 +275,7 @@ func TestLoadTestPostsCommands(t *testing.T) {
}
func TestLeaveCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -322,6 +332,7 @@ func TestLeaveCommands(t *testing.T) {
}
func TestLogoutTestCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -330,6 +341,7 @@ func TestLogoutTestCommand(t *testing.T) {
}
func TestMeCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -357,6 +369,7 @@ func TestMeCommand(t *testing.T) {
}
func TestMsgCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -404,10 +417,12 @@ func TestMsgCommands(t *testing.T) {
}
func TestOpenCommands(t *testing.T) {
mainHelper.Parallel(t)
testJoinCommands(t, "open")
}
func TestSearchCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -416,6 +431,7 @@ func TestSearchCommand(t *testing.T) {
}
func TestSettingsCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -424,6 +440,7 @@ func TestSettingsCommand(t *testing.T) {
}
func TestShortcutsCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -432,6 +449,7 @@ func TestShortcutsCommand(t *testing.T) {
}
func TestShrugCommand(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -452,6 +470,7 @@ func TestShrugCommand(t *testing.T) {
}
func TestStatusCommands(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -25,6 +25,7 @@ const (
)
func TestCORSRequestHandling(t *testing.T) {
mainHelper.Parallel(t)
for name, testcase := range map[string]struct {
AllowCorsFrom string
CorsExposedHeaders string

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

@@ -7,7 +7,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
"testing"
"time"
@@ -17,9 +16,10 @@ import (
)
func TestCreateCPAField(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
th := Setup(t)
mainHelper.Parallel(t)
th := SetupConfig(t, func(cfg *model.Config) {
cfg.FeatureFlags.CustomProfileAttributes = true
})
defer th.TearDown()
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
@@ -96,9 +96,10 @@ func TestCreateCPAField(t *testing.T) {
}
func TestListCPAFields(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
th := Setup(t)
mainHelper.Parallel(t)
th := SetupConfig(t, func(cfg *model.Config) {
cfg.FeatureFlags.CustomProfileAttributes = true
})
defer th.TearDown()
field, err := model.NewCPAFieldFromPropertyField(&model.PropertyField{
@@ -142,9 +143,10 @@ func TestListCPAFields(t *testing.T) {
}
func TestPatchCPAField(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
th := Setup(t)
mainHelper.Parallel(t)
th := SetupConfig(t, func(cfg *model.Config) {
cfg.FeatureFlags.CustomProfileAttributes = true
})
defer th.TearDown()
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
@@ -283,9 +285,10 @@ func TestPatchCPAField(t *testing.T) {
}
func TestDeleteCPAField(t *testing.T) {
os.Setenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_CUSTOMPROFILEATTRIBUTES")
th := Setup(t)
mainHelper.Parallel(t)
th := SetupConfig(t, func(cfg *model.Config) {
cfg.FeatureFlags.CustomProfileAttributes = true
})
defer th.TearDown()
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
@@ -355,9 +358,11 @@ func TestDeleteCPAField(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()
th.RemovePermissionFromRole(model.PermissionViewMembers.Id, model.SystemUserRoleId)
@@ -442,9 +447,11 @@ func TestListCPAValues(t *testing.T) {
}
func TestPatchCPAValues(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()
field, err := model.NewCPAFieldFromPropertyField(&model.PropertyField{

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

@@ -17,6 +17,7 @@ import (
)
func TestDataRetentionGetPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -26,6 +27,7 @@ func TestDataRetentionGetPolicy(t *testing.T) {
}
func TestGetPolicies(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -112,6 +114,7 @@ func TestGetPolicies(t *testing.T) {
}
func TestGetDataRetentionPoliciesCount(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -159,6 +162,7 @@ func TestGetDataRetentionPoliciesCount(t *testing.T) {
}
func TestGetPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -244,6 +248,7 @@ func TestGetPolicy(t *testing.T) {
}
func TestCreatePolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -340,6 +345,7 @@ func TestCreatePolicy(t *testing.T) {
}
func TestPatchPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -455,6 +461,7 @@ func TestPatchPolicy(t *testing.T) {
}
func TestDeletePolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -522,6 +529,7 @@ func TestDeletePolicy(t *testing.T) {
}
func TestGetTeamPoliciesForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -607,6 +615,7 @@ func TestGetTeamPoliciesForUser(t *testing.T) {
}
func TestGetChannelPoliciesForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -692,6 +701,7 @@ func TestGetChannelPoliciesForUser(t *testing.T) {
}
func TestGetTeamsForPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -782,6 +792,7 @@ func TestGetTeamsForPolicy(t *testing.T) {
}
func TestAddTeamsToPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -852,6 +863,7 @@ func TestAddTeamsToPolicy(t *testing.T) {
}
func TestRemoveTeamsFromPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -922,6 +934,7 @@ func TestRemoveTeamsFromPolicy(t *testing.T) {
}
func TestGetChannelsForPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1022,6 +1035,7 @@ func TestGetChannelsForPolicy(t *testing.T) {
}
func TestAddChannelsToPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1141,6 +1155,7 @@ func TestAddChannelsToPolicy(t *testing.T) {
}
func TestRemoveChannelsFromPolicy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -5,7 +5,6 @@ package api4
import (
"context"
"os"
"testing"
"time"
@@ -17,10 +16,7 @@ import (
)
func TestUpsertDraft(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()
@@ -76,8 +72,6 @@ func TestUpsertDraft(t *testing.T) {
CheckForbiddenStatus(t, resp)
// try to upsert draft without config setting set to true
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
_, resp, err = client.UpsertDraft(context.Background(), draft)
@@ -86,10 +80,7 @@ func TestUpsertDraft(t *testing.T) {
}
func TestGetDrafts(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()
@@ -149,8 +140,6 @@ func TestGetDrafts(t *testing.T) {
CheckForbiddenStatus(t, resp)
// try to get drafts when config is turned off
os.Setenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS", "false")
defer os.Unsetenv("MM_SERVICESETTINGS_ALLOWSYNCEDDRAFTS")
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowSyncedDrafts = false })
_, resp, err = client.GetDrafts(context.Background(), user.Id, team.Id)
require.Error(t, err)
@@ -158,10 +147,7 @@ func TestGetDrafts(t *testing.T) {
}
func TestDeleteDraft(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()
@@ -201,7 +187,7 @@ func TestDeleteDraft(t *testing.T) {
_, _, err = client.UpsertDraft(context.Background(), draft2)
require.NoError(t, err)
//get drafts
// get drafts
draftResp, _, err := client.GetDrafts(context.Background(), user.Id, team.Id)
require.NoError(t, err)
@@ -217,7 +203,7 @@ func TestDeleteDraft(t *testing.T) {
_, _, err = client.DeleteDraft(context.Background(), user.Id, channel1.Id, draft1.RootId)
require.NoError(t, err)
//get drafts
// get drafts
draftResp, _, err = client.GetDrafts(context.Background(), user.Id, team.Id)
require.NoError(t, err)

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

@@ -15,6 +15,7 @@ import (
)
func TestElasticsearchTest(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -56,6 +57,7 @@ func TestElasticsearchTest(t *testing.T) {
}
func TestElasticsearchPurgeIndexes(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -22,6 +22,7 @@ import (
)
func TestCreateEmoji(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -212,6 +213,7 @@ func TestCreateEmoji(t *testing.T) {
}
func TestGetEmojiList(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -305,6 +307,7 @@ func TestGetEmojiList(t *testing.T) {
}
func TestGetEmojisByNames(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -385,6 +388,7 @@ func TestGetEmojisByNames(t *testing.T) {
}
func TestDeleteEmoji(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -414,7 +418,7 @@ func TestDeleteEmoji(t *testing.T) {
_, _, err = client.GetEmoji(context.Background(), newEmoji.Id)
require.Error(t, err, "expected error fetching deleted emoji")
//Admin can delete other users emoji
// Admin can delete other users emoji
newEmoji, _, err = client.CreateEmoji(context.Background(), emoji, utils.CreateTestGif(t, 10, 10), "image.gif")
require.NoError(t, err)
@@ -429,17 +433,17 @@ func TestDeleteEmoji(t *testing.T) {
require.Error(t, err)
CheckNotFoundStatus(t, resp)
//Try to delete non-existing emoji
// Try to delete non-existing emoji
resp, err = client.DeleteEmoji(context.Background(), model.NewId())
require.Error(t, err)
CheckNotFoundStatus(t, resp)
//Try to delete without Id
// Try to delete without Id
resp, err = client.DeleteEmoji(context.Background(), "")
require.Error(t, err)
CheckNotFoundStatus(t, resp)
//Try to delete my custom emoji without permissions
// Try to delete my custom emoji without permissions
newEmoji, _, err = client.CreateEmoji(context.Background(), emoji, utils.CreateTestGif(t, 10, 10), "image.gif")
require.NoError(t, err)
@@ -449,7 +453,7 @@ func TestDeleteEmoji(t *testing.T) {
CheckForbiddenStatus(t, resp)
th.AddPermissionToRole(model.PermissionDeleteEmojis.Id, model.SystemUserRoleId)
//Try to delete other user's custom emoji without DELETE_EMOJIS permissions
// Try to delete other user's custom emoji without DELETE_EMOJIS permissions
emoji = &model.Emoji{
CreatorId: th.BasicUser.Id,
Name: model.NewId(),
@@ -476,7 +480,7 @@ func TestDeleteEmoji(t *testing.T) {
require.NoError(t, err)
th.LoginBasic()
//Try to delete other user's custom emoji without DELETE_OTHERS_EMOJIS permissions
// Try to delete other user's custom emoji without DELETE_OTHERS_EMOJIS permissions
emoji = &model.Emoji{
CreatorId: th.BasicUser.Id,
Name: model.NewId(),
@@ -497,7 +501,7 @@ func TestDeleteEmoji(t *testing.T) {
require.NoError(t, err)
th.LoginBasic()
//Try to delete other user's custom emoji with permissions
// Try to delete other user's custom emoji with permissions
emoji = &model.Emoji{
CreatorId: th.BasicUser.Id,
Name: model.NewId(),
@@ -520,7 +524,7 @@ func TestDeleteEmoji(t *testing.T) {
require.NoError(t, err)
th.LoginBasic()
//Try to delete my custom emoji with permissions at team level
// Try to delete my custom emoji with permissions at team level
newEmoji, _, err = client.CreateEmoji(context.Background(), emoji, utils.CreateTestGif(t, 10, 10), "image.gif")
require.NoError(t, err)
@@ -531,7 +535,7 @@ func TestDeleteEmoji(t *testing.T) {
th.AddPermissionToRole(model.PermissionDeleteEmojis.Id, model.SystemUserRoleId)
th.RemovePermissionFromRole(model.PermissionDeleteEmojis.Id, model.TeamUserRoleId)
//Try to delete other user's custom emoji with permissions at team level
// Try to delete other user's custom emoji with permissions at team level
emoji = &model.Emoji{
CreatorId: th.BasicUser.Id,
Name: model.NewId(),
@@ -555,6 +559,7 @@ func TestDeleteEmoji(t *testing.T) {
}
func TestGetEmoji(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -583,6 +588,7 @@ func TestGetEmoji(t *testing.T) {
}
func TestGetEmojiByName(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -613,6 +619,7 @@ func TestGetEmojiByName(t *testing.T) {
}
func TestGetEmojiImage(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -708,6 +715,7 @@ func TestGetEmojiImage(t *testing.T) {
}
func TestSearchEmoji(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -810,6 +818,7 @@ func TestSearchEmoji(t *testing.T) {
}
func TestAutocompleteEmoji(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client

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

@@ -17,6 +17,7 @@ import (
)
func TestListExports(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -87,6 +88,7 @@ func TestListExports(t *testing.T) {
}
func TestDeleteExport(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -131,6 +133,7 @@ func TestDeleteExport(t *testing.T) {
}
func TestDownloadExport(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -205,6 +205,7 @@ func testUploadFilesMultipart(
}
func TestUploadFiles(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
if *th.App.Config().FileSettings.DriverName == "" {
@@ -781,6 +782,7 @@ func TestUploadFiles(t *testing.T) {
}
func TestGetFile(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -822,6 +824,7 @@ func TestGetFile(t *testing.T) {
}
func TestGetFileAsSystemAdmin(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -907,6 +910,7 @@ func TestGetFileAsSystemAdmin(t *testing.T) {
}
func TestGetFileHeaders(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -975,6 +979,7 @@ func TestGetFileHeaders(t *testing.T) {
}
func TestGetFileThumbnail(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1025,6 +1030,7 @@ func TestGetFileThumbnail(t *testing.T) {
}
func TestGetFileThumbnailAsSystemAdmin(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1112,6 +1118,7 @@ func TestGetFileThumbnailAsSystemAdmin(t *testing.T) {
}
func TestGetFileLink(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1183,6 +1190,7 @@ func TestGetFileLink(t *testing.T) {
}
func TestGetFilePreview(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1232,6 +1240,7 @@ func TestGetFilePreview(t *testing.T) {
}
func TestGetFileInfo(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1289,6 +1298,7 @@ func TestGetFileInfo(t *testing.T) {
}
func TestGetPublicFile(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1352,6 +1362,7 @@ func TestGetPublicFile(t *testing.T) {
}
func TestSearchFilesInTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
experimentalViewArchivedChannels := *th.App.Config().TeamSettings.ExperimentalViewArchivedChannels
@@ -1502,6 +1513,7 @@ func TestSearchFilesInTeam(t *testing.T) {
}
func TestSearchFilesAcrossTeams(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
experimentalViewArchivedChannels := *th.App.Config().TeamSettings.ExperimentalViewArchivedChannels

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

@@ -18,6 +18,7 @@ import (
)
func TestGetGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -69,6 +70,7 @@ func TestGetGroup(t *testing.T) {
}
func TestCreateGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -179,6 +181,7 @@ func TestCreateGroup(t *testing.T) {
}
func TestDeleteGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -224,6 +227,7 @@ func TestDeleteGroup(t *testing.T) {
}
func TestUndeleteGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -256,6 +260,7 @@ func TestUndeleteGroup(t *testing.T) {
}
func TestPatchGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -359,6 +364,7 @@ func TestPatchGroup(t *testing.T) {
}
func TestLinkGroupTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -472,6 +478,7 @@ func TestLinkGroupTeam(t *testing.T) {
}
func TestLinkGroupChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -597,6 +604,7 @@ func TestLinkGroupChannel(t *testing.T) {
}
func TestUnlinkGroupTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -716,6 +724,7 @@ func TestUnlinkGroupTeam(t *testing.T) {
}
func TestUnlinkGroupChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -997,6 +1006,7 @@ func TestUnlinkGroupChannel(t *testing.T) {
}
func TestGetGroupTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1060,6 +1070,7 @@ func TestGetGroupTeam(t *testing.T) {
}
func TestGetGroupChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1123,6 +1134,7 @@ func TestGetGroupChannel(t *testing.T) {
}
func TestGetGroupTeams(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1177,6 +1189,7 @@ func TestGetGroupTeams(t *testing.T) {
}
func TestGetGroupChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1230,6 +1243,7 @@ func TestGetGroupChannels(t *testing.T) {
}
func TestPatchGroupTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1303,6 +1317,7 @@ func TestPatchGroupTeam(t *testing.T) {
}
func TestPatchGroupChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1387,6 +1402,7 @@ func TestPatchGroupChannel(t *testing.T) {
}
func TestGetGroupsByChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1530,6 +1546,7 @@ func TestGetGroupsByChannel(t *testing.T) {
}
func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1682,6 +1699,7 @@ func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
}
func TestGetGroupsByTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1874,6 +1892,7 @@ func TestGetGroupsByTeam(t *testing.T) {
}
func TestGetGroups(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2256,6 +2275,7 @@ func TestGetGroups(t *testing.T) {
}
func TestGetGroupsByUserId(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2327,6 +2347,7 @@ func TestGetGroupsByUserId(t *testing.T) {
}
func TestGetGroupMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2394,6 +2415,7 @@ func TestGetGroupMembers(t *testing.T) {
}
func TestGetGroupStats(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2443,6 +2465,7 @@ func TestGetGroupStats(t *testing.T) {
}
func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -2526,6 +2549,7 @@ func TestGetGroupsGroupConstrainedParentTeam(t *testing.T) {
}
func TestAddMembersToGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -2699,6 +2723,7 @@ func TestAddMembersToGroup(t *testing.T) {
}
func TestDeleteMembersFromGroup(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -69,6 +69,7 @@ func testAPIHandlerNoGzipMode(t *testing.T, name string, h http.Handler, token s
}
func TestAPIHandlersWithGzip(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -18,6 +18,7 @@ import (
)
func TestGetImage(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -20,6 +20,7 @@ import (
)
func TestListImports(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -110,6 +111,7 @@ func TestListImports(t *testing.T) {
}
func TestImportInLocalMode(t *testing.T) {
mainHelper.Parallel(t)
th := SetupWithServerOptions(t, []app.Option{app.RunEssentialJobs})
defer th.TearDown()

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

@@ -47,6 +47,7 @@ func (th *testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func TestPostActionCookies(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -148,6 +149,7 @@ func TestPostActionCookies(t *testing.T) {
}
func TestOpenDialog(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -285,6 +287,7 @@ func TestOpenDialog(t *testing.T) {
}
func TestSubmitDialog(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client

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

@@ -16,6 +16,7 @@ import (
)
func TestCreateJob(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
th.LoginSystemManager()
defer th.TearDown()
@@ -50,6 +51,7 @@ func TestCreateJob(t *testing.T) {
}
func TestGetJob(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -86,6 +88,7 @@ func TestGetJob(t *testing.T) {
}
func TestGetJobs(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -170,6 +173,7 @@ func TestGetJobs(t *testing.T) {
}
func TestGetJobsByType(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
th.LoginSystemManager()
defer th.TearDown()
@@ -239,6 +243,7 @@ func TestGetJobsByType(t *testing.T) {
}
func TestDownloadJob(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
th.LoginSystemManager()
defer th.TearDown()
@@ -280,7 +285,7 @@ func TestDownloadJob(t *testing.T) {
require.NoError(t, delErr, "Failed to delete job %s", job.Id)
}()
filePath := filepath.Join(*th.App.Config().FileSettings.Directory, "export", job.Id+"/testdat.txt")
filePath := filepath.Join(*th.App.Config().FileSettings.Directory, "export/"+job.Id+"/testdat.txt")
err = os.MkdirAll(filepath.Dir(filePath), 0770)
require.NoError(t, err)
@@ -314,7 +319,7 @@ func TestDownloadJob(t *testing.T) {
// Now we stub the results of the job into the same directory and try to download it again
// This time we should successfully retrieve the results without any error
filePath = filepath.Join(*th.App.Config().FileSettings.Directory, "export", job.Id+".zip")
filePath = filepath.Join(*th.App.Config().FileSettings.Directory, "export/"+job.Id+".zip")
err = os.MkdirAll(filepath.Dir(filePath), 0770)
require.NoError(t, err)
@@ -372,6 +377,7 @@ func TestDownloadJob(t *testing.T) {
}
func TestCancelJob(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -422,6 +428,7 @@ func TestCancelJob(t *testing.T) {
}
func TestUpdateJobStatus(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -101,6 +101,7 @@ MCOV5SHi05kD42JSSbmw190VAa4QRGikaeWRhDsj
-----END CERTIFICATE-----`
func TestTestLdap(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -127,6 +128,7 @@ func TestTestLdap(t *testing.T) {
}
func TestSyncLdap(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -175,6 +177,7 @@ func TestSyncLdap(t *testing.T) {
}
func TestGetLdapGroups(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -190,6 +193,7 @@ func TestGetLdapGroups(t *testing.T) {
}
func TestLinkLdapGroup(t *testing.T) {
mainHelper.Parallel(t)
const entryUUID string = "foo"
th := Setup(t)
@@ -205,6 +209,7 @@ func TestLinkLdapGroup(t *testing.T) {
}
func TestUnlinkLdapGroup(t *testing.T) {
mainHelper.Parallel(t)
const entryUUID string = "foo"
th := Setup(t)
@@ -220,6 +225,7 @@ func TestUnlinkLdapGroup(t *testing.T) {
}
func TestMigrateIdLdap(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -239,6 +245,7 @@ func TestMigrateIdLdap(t *testing.T) {
}
func TestUploadPublicCertificate(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -260,6 +267,7 @@ func TestUploadPublicCertificate(t *testing.T) {
}
func TestUploadPrivateCertificate(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -281,6 +289,7 @@ func TestUploadPrivateCertificate(t *testing.T) {
}
func TestAddUserToGroupSyncables(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -22,6 +22,7 @@ import (
)
func TestGetOldClientLicense(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -193,6 +194,7 @@ func TestUploadLicenseFile(t *testing.T) {
}
func TestRemoveLicenseFile(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -407,6 +409,7 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
}
func TestRequestTrialLicense(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -5,8 +5,11 @@ package api4
import (
"flag"
"os"
"strconv"
"testing"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/v8/channels/testlib"
)
@@ -18,10 +21,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)

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

@@ -35,6 +35,7 @@ func setupMetricsMock() *mocks.MetricsInterface {
return metricsMock
}
func TestSubmitMetrics(t *testing.T) {
t.Run("unauthenticated user should not submit metrics", func(t *testing.T) {
th := Setup(t)

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

@@ -13,7 +13,9 @@ import (
)
func TestNotifyAdmin(t *testing.T) {
mainHelper.Parallel(t)
t.Run("error when notifying with empty data", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -24,6 +26,7 @@ func TestNotifyAdmin(t *testing.T) {
})
t.Run("error when plan is unknown when notifying on upgrade", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -38,6 +41,7 @@ func TestNotifyAdmin(t *testing.T) {
})
t.Run("error when plan is unknown when notifying to trial", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -53,6 +57,7 @@ func TestNotifyAdmin(t *testing.T) {
})
t.Run("error when feature is unknown when notifying on upgrade", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -67,6 +72,7 @@ func TestNotifyAdmin(t *testing.T) {
})
t.Run("error when feature is unknown when notifying to trial", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -82,6 +88,7 @@ func TestNotifyAdmin(t *testing.T) {
})
t.Run("error when user tries to notify again on same feature within the cool off period", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -104,6 +111,7 @@ func TestNotifyAdmin(t *testing.T) {
})
t.Run("successfully save upgrade notification", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -118,7 +126,9 @@ func TestNotifyAdmin(t *testing.T) {
}
func TestTriggerNotifyAdmin(t *testing.T) {
mainHelper.Parallel(t)
t.Run("error when EnableAPITriggerAdminNotifications is not true", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -132,6 +142,7 @@ func TestTriggerNotifyAdmin(t *testing.T) {
})
t.Run("error when non admins try to trigger notifications", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -145,6 +156,7 @@ func TestTriggerNotifyAdmin(t *testing.T) {
})
t.Run("happy path", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -15,6 +15,7 @@ import (
)
func TestCreateOAuthApp(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -80,6 +81,8 @@ func TestCreateOAuthApp(t *testing.T) {
func TestUpdateOAuthApp(t *testing.T) {
t.Skip("https://mattermost.atlassian.net/browse/MM-62895")
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -203,6 +206,7 @@ func TestUpdateOAuthApp(t *testing.T) {
}
func TestGetOAuthApps(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -273,6 +277,7 @@ func TestGetOAuthApps(t *testing.T) {
}
func TestGetOAuthApp(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -344,6 +349,7 @@ func TestGetOAuthApp(t *testing.T) {
}
func TestGetOAuthAppInfo(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -413,6 +419,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
}
func TestDeleteOAuthApp(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -486,6 +493,7 @@ func TestDeleteOAuthApp(t *testing.T) {
}
func TestRegenerateOAuthAppSecret(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -561,6 +569,7 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
}
func TestGetAuthorizedOAuthAppsForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -619,6 +628,7 @@ func TestGetAuthorizedOAuthAppsForUser(t *testing.T) {
}
func TestNilAuthorizeOAuthApp(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client

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

@@ -14,6 +14,7 @@ import (
)
func TestGetAncillaryPermissions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -32,6 +32,7 @@ import (
)
func TestPlugin(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -286,6 +287,7 @@ func TestPlugin(t *testing.T) {
}
func TestNotifyClusterPluginEvent(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -378,6 +380,7 @@ func TestNotifyClusterPluginEvent(t *testing.T) {
}
func TestDisableOnRemove(t *testing.T) {
mainHelper.Parallel(t)
path, _ := fileutils.FindDir("tests")
tarData, err := os.ReadFile(filepath.Join(path, "testplugin.tar.gz"))
require.NoError(t, err)
@@ -1139,6 +1142,7 @@ func TestGetLocalPluginInMarketplace(t *testing.T) {
}
func TestGetRemotePluginInMarketplace(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1328,6 +1332,7 @@ func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
}
func TestGetPrepackagedPlaybooksPluginIn(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1756,6 +1761,7 @@ func TestInstallMarketplacePlugin(t *testing.T) {
}
func TestInstallMarketplacePluginPrepackagedDisabled(t *testing.T) {
mainHelper.Parallel(t)
path, _ := fileutils.FindDir("tests")
signatureFilename := "testplugin2.tar.gz.sig"
@@ -2093,6 +2099,7 @@ func findClusterMessages(event model.ClusterEvent, msgs []*model.ClusterMessage)
}
func TestPluginWebSocketSession(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2145,6 +2152,7 @@ func TestPluginWebSocketSession(t *testing.T) {
}
func TestPluginWebSocketRemoteAddress(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -34,6 +34,8 @@ import (
)
func TestCreatePost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -304,6 +306,8 @@ func TestCreatePost(t *testing.T) {
}
func TestCreatePostForPriority(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -477,6 +481,7 @@ func TestCreatePostForPriority(t *testing.T) {
}
func TestCreatePostWithOAuthClient(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -545,6 +550,8 @@ func TestCreatePostWithOAuthClient(t *testing.T) {
}
func TestCreatePostEphemeral(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.SystemAdminClient
@@ -583,6 +590,8 @@ func testCreatePostWithOutgoingHook(
triggerWhen int,
commentPostType bool,
) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
user := th.SystemAdminUser
@@ -1089,6 +1098,8 @@ func TestMoveThread(t *testing.T) {
}
func TestCreatePostPublic(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1146,6 +1157,8 @@ func TestCreatePostPublic(t *testing.T) {
}
func TestCreatePostAll(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1212,6 +1225,8 @@ func TestCreatePostAll(t *testing.T) {
}
func TestCreatePostSendOutOfChannelMentions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1274,6 +1289,8 @@ func TestCreatePostSendOutOfChannelMentions(t *testing.T) {
}
func TestCreatePostCheckOnlineStatus(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1340,6 +1357,8 @@ func TestCreatePostCheckOnlineStatus(t *testing.T) {
}
func TestUpdatePost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1690,6 +1709,8 @@ func TestUpdatePost(t *testing.T) {
}
func TestUpdateOthersPostInDirectMessageChannel(t *testing.T) {
mainHelper.Parallel(t)
// This test checks that a sysadmin with the "EDIT_OTHERS_POSTS" permission can edit someone else's post in a
// channel without a team (DM/GM). This indirectly checks for the proper cascading all the way to system-wide roles
// on the user object of permissions based on a post in a channel with no team ID.
@@ -1715,6 +1736,8 @@ func TestUpdateOthersPostInDirectMessageChannel(t *testing.T) {
}
func TestPatchPost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2041,6 +2064,8 @@ func TestPatchPost(t *testing.T) {
}
func TestPinPost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2072,6 +2097,8 @@ func TestPinPost(t *testing.T) {
}
func TestUnpinPost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2103,6 +2130,8 @@ func TestUnpinPost(t *testing.T) {
}
func TestGetPostsForChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2346,6 +2375,8 @@ func TestGetPostsForChannel(t *testing.T) {
}
func TestGetFlaggedPostsForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2552,6 +2583,8 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
}
func TestGetPostsBefore(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2719,6 +2752,8 @@ func TestGetPostsBefore(t *testing.T) {
}
func TestGetPostsAfter(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2867,6 +2902,8 @@ func TestGetPostsAfter(t *testing.T) {
}
func TestGetPostsForChannelAroundLastUnread(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3120,6 +3157,8 @@ func TestGetPostsForChannelAroundLastUnread(t *testing.T) {
}
func TestGetPost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
// TODO: migrate this entirely to the subtest's client
@@ -3219,6 +3258,8 @@ func TestGetPost(t *testing.T) {
}
func TestDeletePost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3275,6 +3316,8 @@ func TestDeletePost(t *testing.T) {
}
func TestPermanentDeletePost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3352,7 +3395,11 @@ func TestPermanentDeletePost(t *testing.T) {
}
func TestWebHubMembership(t *testing.T) {
mainHelper.Parallel(t)
t.Run("WithChannelIteration", func(t *testing.T) {
mainHelper.Parallel(t)
th := SetupConfig(t, func(cfg *model.Config) {
*cfg.ServiceSettings.EnableWebHubChannelIteration = true
}).InitBasic()
@@ -3362,6 +3409,8 @@ func TestWebHubMembership(t *testing.T) {
})
t.Run("WithoutChannelIteration", func(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3490,6 +3539,8 @@ func _testWebHubMembership(th *TestHelper, t *testing.T) {
}
func TestWebHubCloseConnOnDBFail(t *testing.T) {
mainHelper.Parallel(t)
th := SetupConfig(t, func(cfg *model.Config) {
*cfg.ServiceSettings.EnableWebHubChannelIteration = true
}).InitBasic()
@@ -3510,12 +3561,21 @@ func TestWebHubCloseConnOnDBFail(t *testing.T) {
wsClient, err := th.CreateWebSocketClientWithClient(cli)
require.NoError(t, err)
wsClient.Listen()
select {
case <-wsClient.EventChannel: // event channel should be closed on failure
case <-time.After(5 * time.Second):
require.FailNow(t, "timed out waiting for event")
}
wsClient.Close()
require.NoError(t, th.TestLogger.Flush())
}
func TestDeletePostEvent(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3543,6 +3603,8 @@ func TestDeletePostEvent(t *testing.T) {
}
func TestDeletePostMessage(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
th.LinkUserToTeam(th.SystemAdminUser, th.BasicTeam)
_, appErr := th.App.AddUserToChannel(th.Context, th.SystemAdminUser, th.BasicChannel, false)
@@ -3589,6 +3651,8 @@ func TestDeletePostMessage(t *testing.T) {
}
func TestGetPostThread(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3718,6 +3782,8 @@ func TestGetPostThread(t *testing.T) {
}
func TestSearchPosts(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
experimentalViewArchivedChannels := *th.App.Config().TeamSettings.ExperimentalViewArchivedChannels
@@ -3870,6 +3936,8 @@ func TestSearchPosts(t *testing.T) {
}
func TestSearchHashtagPosts(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.LoginBasic()
@@ -3896,6 +3964,8 @@ func TestSearchHashtagPosts(t *testing.T) {
}
func TestSearchPostsInChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.LoginBasic()
@@ -3950,6 +4020,8 @@ func TestSearchPostsInChannel(t *testing.T) {
}
func TestSearchPostsFromUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4018,6 +4090,8 @@ func TestSearchPostsFromUser(t *testing.T) {
}
func TestSearchPostsWithDateFlags(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.LoginBasic()
@@ -4161,6 +4235,8 @@ func TestGetFileInfosForPost(t *testing.T) {
}
func TestSetChannelUnread(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -4335,6 +4411,8 @@ func TestSetChannelUnread(t *testing.T) {
}
func TestSetPostUnreadWithoutCollapsedThreads(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) {
@@ -4430,6 +4508,8 @@ func TestSetPostUnreadWithoutCollapsedThreads(t *testing.T) {
}
func TestGetPostsByIds(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4454,6 +4534,8 @@ func TestGetPostsByIds(t *testing.T) {
}
func TestGetEditHistoryForPost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4574,6 +4656,8 @@ func TestGetEditHistoryForPost(t *testing.T) {
}
func TestCreatePostNotificationsWithCRT(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
rpost := th.CreatePost()
@@ -4727,6 +4811,8 @@ func TestCreatePostNotificationsWithCRT(t *testing.T) {
}
func TestGetPostStripActionIntegrations(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4838,6 +4924,8 @@ func TestPostReminder(t *testing.T) {
}
func TestPostGetInfo(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -5107,6 +5195,8 @@ func TestPostGetInfo(t *testing.T) {
}
func TestAcknowledgePost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
@@ -5148,6 +5238,8 @@ func TestAcknowledgePost(t *testing.T) {
}
func TestUnacknowledgePost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
@@ -5193,6 +5285,8 @@ func TestUnacknowledgePost(t *testing.T) {
}
func TestRestorePostVersion(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client

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

@@ -16,6 +16,7 @@ import (
)
func TestGetPreferences(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -87,6 +88,7 @@ func TestGetPreferences(t *testing.T) {
}
func TestGetPreferencesByCategory(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -157,6 +159,7 @@ func TestGetPreferencesByCategory(t *testing.T) {
}
func TestGetPreferenceByCategoryAndName(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -226,6 +229,7 @@ func TestGetPreferenceByCategoryAndName(t *testing.T) {
}
func TestUpdatePreferences(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -305,6 +309,7 @@ func TestUpdatePreferences(t *testing.T) {
}
func TestUpdatePreferencesOverload(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -341,6 +346,7 @@ func TestUpdatePreferencesOverload(t *testing.T) {
}
func TestUpdatePreferencesWebsocket(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -392,6 +398,7 @@ func TestUpdatePreferencesWebsocket(t *testing.T) {
}
func TestUpdateSidebarPreferences(t *testing.T) {
mainHelper.Parallel(t)
t.Run("when favoriting a channel, should add it to the Favorites sidebar category", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -619,6 +626,7 @@ func TestUpdateSidebarPreferences(t *testing.T) {
}
func TestDeletePreferences(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -689,6 +697,7 @@ func TestDeletePreferences(t *testing.T) {
}
func TestDeletePreferencesOverload(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -725,6 +734,7 @@ func TestDeletePreferencesOverload(t *testing.T) {
}
func TestDeletePreferencesWebsocket(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -778,6 +788,7 @@ func TestDeletePreferencesWebsocket(t *testing.T) {
}
func TestDeleteSidebarPreferences(t *testing.T) {
mainHelper.Parallel(t)
t.Run("when removing a favorited channel preference, should remove it from the Favorites sidebar category", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -993,6 +1004,7 @@ func TestDeleteSidebarPreferences(t *testing.T) {
}
func TestUpdateLimitVisibleDMsGMs(t *testing.T) {
mainHelper.Parallel(t)
t.Run("Update limit_visible_dms_gms to a valid value", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -15,6 +15,7 @@ import (
)
func TestSaveReaction(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -195,6 +196,7 @@ func TestSaveReaction(t *testing.T) {
}
func TestGetReactions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -278,6 +280,7 @@ func TestGetReactions(t *testing.T) {
}
func TestDeleteReaction(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -519,6 +522,7 @@ func TestDeleteReaction(t *testing.T) {
}
func TestGetBulkReactions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client

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

@@ -13,6 +13,7 @@ import (
)
func TestGetRemoteClusters(t *testing.T) {
mainHelper.Parallel(t)
t.Run("Should not work if the remote cluster service is not enabled", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -182,6 +183,7 @@ func TestGetRemoteClusters(t *testing.T) {
}
func TestCreateRemoteCluster(t *testing.T) {
mainHelper.Parallel(t)
rcWithTeamAndPassword := &model.RemoteClusterWithPassword{
RemoteCluster: &model.RemoteCluster{
Name: "remotecluster",
@@ -294,6 +296,7 @@ func TestCreateRemoteCluster(t *testing.T) {
}
func TestRemoteClusterAcceptinvite(t *testing.T) {
mainHelper.Parallel(t)
rcAcceptInvite := &model.RemoteClusterAcceptInvite{
Name: "remotecluster",
Invite: "myinvitecode",
@@ -392,6 +395,7 @@ func TestRemoteClusterAcceptinvite(t *testing.T) {
}
func TestGenerateRemoteClusterInvite(t *testing.T) {
mainHelper.Parallel(t)
password := "mysupersecret"
newRC := &model.RemoteCluster{
@@ -482,6 +486,7 @@ func TestGenerateRemoteClusterInvite(t *testing.T) {
}
func TestGetRemoteCluster(t *testing.T) {
mainHelper.Parallel(t)
newRC := &model.RemoteCluster{
Name: "remotecluster",
SiteURL: "http://example.com",
@@ -540,6 +545,7 @@ func TestGetRemoteCluster(t *testing.T) {
}
func TestPatchRemoteCluster(t *testing.T) {
mainHelper.Parallel(t)
newRC := &model.RemoteCluster{
Name: "remotecluster",
DisplayName: "initialvalue",
@@ -604,6 +610,7 @@ func TestPatchRemoteCluster(t *testing.T) {
}
func TestDeleteRemoteCluster(t *testing.T) {
mainHelper.Parallel(t)
newRC := &model.RemoteCluster{
Name: "remotecluster",
DisplayName: "initialvalue",

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

@@ -14,6 +14,7 @@ import (
)
func TestGetUsersForReporting(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -59,6 +60,7 @@ func TestGetUsersForReporting(t *testing.T) {
}
func TestFillReportingBaseOptions(t *testing.T) {
mainHelper.Parallel(t)
t.Run("default values", func(t *testing.T) {
values := url.Values{}
@@ -114,6 +116,7 @@ func TestFillReportingBaseOptions(t *testing.T) {
}
func TestFillUserReportOptions(t *testing.T) {
mainHelper.Parallel(t)
validTeamID := model.NewId()
t.Run("default values", func(t *testing.T) {

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

@@ -17,6 +17,7 @@ import (
)
func TestGetAllRoles(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -39,6 +40,7 @@ func TestGetAllRoles(t *testing.T) {
}
func TestGetRole(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -81,6 +83,7 @@ func TestGetRole(t *testing.T) {
}
func TestGetRoleByName(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -123,6 +126,7 @@ func TestGetRoleByName(t *testing.T) {
}
func TestGetRolesByNames(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -215,6 +219,7 @@ func TestGetRolesByNames(t *testing.T) {
}
func TestPatchRole(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -15,6 +15,7 @@ import (
)
func TestGetSamlMetadata(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -27,6 +28,7 @@ func TestGetSamlMetadata(t *testing.T) {
}
func TestSamlCompleteCSRFPass(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -55,6 +57,7 @@ func TestSamlCompleteCSRFPass(t *testing.T) {
}
func TestSamlResetId(t *testing.T) {
mainHelper.Parallel(t)
th := SetupEnterprise(t).InitBasic()
defer th.TearDown()
th.App.Channels().Saml = &mocks.SamlInterface{}

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

@@ -12,6 +12,7 @@ import (
)
func TestCreateScheduledPost(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -15,6 +15,7 @@ import (
)
func TestCreateScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -193,6 +194,7 @@ func TestCreateScheme(t *testing.T) {
}
func TestGetScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -260,6 +262,7 @@ func TestGetScheme(t *testing.T) {
}
func TestGetSchemes(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -328,6 +331,7 @@ func TestGetSchemes(t *testing.T) {
}
func TestGetTeamsForScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -425,6 +429,7 @@ func TestGetTeamsForScheme(t *testing.T) {
}
func TestGetChannelsForScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -524,6 +529,7 @@ func TestGetChannelsForScheme(t *testing.T) {
}
func TestPatchScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -652,6 +658,7 @@ func TestPatchScheme(t *testing.T) {
}
func TestDeleteScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -871,6 +878,7 @@ func TestDeleteScheme(t *testing.T) {
}
func TestUpdateTeamSchemeWithTeamMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()

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

@@ -18,9 +18,7 @@ import (
"github.com/mattermost/mattermost/server/public/model"
)
var (
rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
)
var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
func setupForSharedChannels(tb testing.TB) *TestHelper {
th := SetupConfig(tb, func(cfg *model.Config) {
@@ -36,6 +34,7 @@ func setupForSharedChannels(tb testing.TB) *TestHelper {
}
func TestGetAllSharedChannels(t *testing.T) {
mainHelper.Parallel(t)
th := setupForSharedChannels(t).InitBasic()
defer th.TearDown()
@@ -107,6 +106,7 @@ func randomBool() bool {
}
func TestGetRemoteClusterById(t *testing.T) {
mainHelper.Parallel(t)
th := setupForSharedChannels(t).InitBasic()
defer th.TearDown()
@@ -161,6 +161,7 @@ func TestGetRemoteClusterById(t *testing.T) {
}
func TestCreateDirectChannelWithRemoteUser(t *testing.T) {
mainHelper.Parallel(t)
t.Run("should not create a local DM channel that is shared", func(t *testing.T) {
th := setupForSharedChannels(t).InitBasic()
defer th.TearDown()
@@ -276,6 +277,7 @@ func TestCreateDirectChannelWithRemoteUser(t *testing.T) {
}
func TestGetSharedChannelRemotesByRemoteCluster(t *testing.T) {
mainHelper.Parallel(t)
t.Run("Should not work if the remote cluster service is not enabled", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -534,6 +536,7 @@ func TestGetSharedChannelRemotesByRemoteCluster(t *testing.T) {
}
func TestInviteRemoteClusterToChannel(t *testing.T) {
mainHelper.Parallel(t)
t.Run("Should not work if the remote cluster service is not enabled", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -579,6 +582,7 @@ func TestInviteRemoteClusterToChannel(t *testing.T) {
}
func TestUninviteRemoteClusterToChannel(t *testing.T) {
mainHelper.Parallel(t)
t.Run("Should not work if the remote cluster service is not enabled", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()

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

@@ -15,6 +15,7 @@ import (
)
func TestGetUserStatus(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -79,7 +80,7 @@ func TestGetUserStatus(t *testing.T) {
})
t.Run("get other user status", func(t *testing.T) {
//Get user2 status logged as user1
// Get user2 status logged as user1
userStatus, _, err := client.GetUserStatus(context.Background(), th.BasicUser2.Id, "")
require.NoError(t, err)
assert.Equal(t, "offline", userStatus.Status)
@@ -102,6 +103,7 @@ func TestGetUserStatus(t *testing.T) {
}
func TestGetUsersStatusesByIds(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -185,6 +187,7 @@ func TestGetUsersStatusesByIds(t *testing.T) {
}
func TestUpdateUserStatus(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -249,6 +252,7 @@ func TestUpdateUserStatus(t *testing.T) {
}
func TestUpdateUserCustomStatus(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -351,6 +355,7 @@ func TestUpdateUserCustomStatus(t *testing.T) {
}
func TestRemoveUserCustomStatus(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client

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

@@ -111,6 +111,7 @@ func TestGetPing(t *testing.T) {
}
func TestGetAudits(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -143,6 +144,7 @@ func TestGetAudits(t *testing.T) {
}
func TestEmailTest(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -224,6 +226,7 @@ func TestEmailTest(t *testing.T) {
}
func TestGenerateSupportPacket(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
th.LoginSystemManager()
defer th.TearDown()
@@ -283,6 +286,7 @@ func TestGenerateSupportPacket(t *testing.T) {
}
func TestSupportPacketFileName(t *testing.T) {
mainHelper.Parallel(t)
tests := map[string]struct {
now time.Time
customerName string
@@ -314,6 +318,7 @@ func TestSupportPacketFileName(t *testing.T) {
}
func TestSiteURLTest(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -360,6 +365,7 @@ func TestSiteURLTest(t *testing.T) {
}
func TestDatabaseRecycle(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -385,6 +391,7 @@ func TestDatabaseRecycle(t *testing.T) {
}
func TestInvalidateCaches(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -410,6 +417,7 @@ func TestInvalidateCaches(t *testing.T) {
}
func TestGetLogs(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -458,6 +466,7 @@ func TestGetLogs(t *testing.T) {
}
func TestDownloadLogs(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -500,6 +509,7 @@ func TestDownloadLogs(t *testing.T) {
}
func TestPostLog(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -542,6 +552,7 @@ func TestPostLog(t *testing.T) {
}
func TestGetAnalyticsOld(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -595,9 +606,12 @@ func TestGetAnalyticsOld(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "total_websocket_connections", rows2[5].Name)
assert.Equal(t, float64(1), rows2[5].Value)
WebSocketClient.Close()
// Give it a second for internal webhub counters to be updated after the client disconnects.
// Test can be flaky otherwise.
time.Sleep(time.Second)
rows2, _, err = th.SystemAdminClient.GetAnalyticsOld(context.Background(), "standard", "")
require.NoError(t, err)
assert.Equal(t, "total_websocket_connections", rows2[5].Name)
@@ -612,6 +626,7 @@ func TestGetAnalyticsOld(t *testing.T) {
}
func TestS3TestConnection(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -697,6 +712,7 @@ func TestS3TestConnection(t *testing.T) {
}
func TestSupportedTimezones(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -709,6 +725,7 @@ func TestSupportedTimezones(t *testing.T) {
}
func TestRedirectLocation(t *testing.T) {
mainHelper.Parallel(t)
expected := "https://mattermost.com/wp-content/themes/mattermostv2/img/logo-light.svg"
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
@@ -799,6 +816,7 @@ func TestRedirectLocation(t *testing.T) {
}
func TestSetServerBusy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -819,6 +837,7 @@ func TestSetServerBusy(t *testing.T) {
}
func TestSetServerBusyInvalidParam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -834,6 +853,7 @@ func TestSetServerBusyInvalidParam(t *testing.T) {
}
func TestClearServerBusy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -854,6 +874,7 @@ func TestClearServerBusy(t *testing.T) {
}
func TestGetServerBusy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -874,6 +895,7 @@ func TestGetServerBusy(t *testing.T) {
}
func TestServerBusy503(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -917,6 +939,7 @@ func TestServerBusy503(t *testing.T) {
}
func TestPushNotificationAck(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
api, err := Init(th.Server)
require.NoError(t, err)
@@ -1010,6 +1033,7 @@ func TestPushNotificationAck(t *testing.T) {
}
func TestCompleteOnboarding(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1143,6 +1167,7 @@ func TestCompleteOnboarding(t *testing.T) {
}
func TestGetAppliedSchemaMigrations(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1170,6 +1195,7 @@ func TestGetAppliedSchemaMigrations(t *testing.T) {
}
func TestCheckHasNilFields(t *testing.T) {
mainHelper.Parallel(t)
t.Run("check if the empty struct has nil fields", func(t *testing.T) {
var s model.FileSettings
res := checkHasNilFields(&s)

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

@@ -28,6 +28,7 @@ import (
)
func TestCreateTeam(t *testing.T) {
// Test cannot easily run in parallel because it relies on (and mutates) i18n package translations.
th := Setup(t)
defer th.TearDown()
@@ -198,6 +199,7 @@ func TestCreateTeam(t *testing.T) {
}
func TestCreateTeamSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -235,6 +237,7 @@ func TestCreateTeamSanitization(t *testing.T) {
}
func TestGetTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -291,6 +294,7 @@ func TestGetTeam(t *testing.T) {
}
func TestGetTeamSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -360,6 +364,7 @@ func TestGetTeamSanitization(t *testing.T) {
}
func TestGetTeamUnread(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -396,6 +401,7 @@ func TestGetTeamUnread(t *testing.T) {
}
func TestUpdateTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -580,6 +586,7 @@ func TestUpdateTeamPrivacyInvitePermissions(t *testing.T) {
}
func TestUpdateTeamSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -612,6 +619,7 @@ func TestUpdateTeamSanitization(t *testing.T) {
}
func TestPatchTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -880,6 +888,7 @@ func TestPatchTeam(t *testing.T) {
}
func TestRestoreTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -1007,6 +1016,7 @@ func TestRestoreTeam(t *testing.T) {
}
func TestPatchTeamSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1039,6 +1049,7 @@ func TestPatchTeamSanitization(t *testing.T) {
}
func TestUpdateTeamPrivacy(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -1131,6 +1142,7 @@ func TestUpdateTeamPrivacy(t *testing.T) {
}
func TestTeamUnicodeNames(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -1201,6 +1213,7 @@ func TestTeamUnicodeNames(t *testing.T) {
}
func TestRegenerateTeamInviteId(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
client := th.Client
@@ -1225,6 +1238,7 @@ func TestRegenerateTeamInviteId(t *testing.T) {
}
func TestSoftDeleteTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1262,6 +1276,7 @@ func TestSoftDeleteTeam(t *testing.T) {
}
func TestPermanentDeleteTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1313,6 +1328,7 @@ func TestPermanentDeleteTeam(t *testing.T) {
}
func TestGetAllTeams(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
th.LoginSystemManager()
defer th.TearDown()
@@ -1579,6 +1595,7 @@ func TestGetAllTeams(t *testing.T) {
}
func TestGetAllTeamsSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -1640,6 +1657,7 @@ func TestGetAllTeamsSanitization(t *testing.T) {
}
func TestGetTeamByName(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
team := th.BasicTeam
@@ -1694,6 +1712,7 @@ func TestGetTeamByName(t *testing.T) {
}
func TestGetTeamByNameSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1764,6 +1783,7 @@ func TestGetTeamByNameSanitization(t *testing.T) {
}
func TestSearchAllTeams(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
th.LoginSystemManager()
defer th.TearDown()
@@ -1871,6 +1891,7 @@ func TestSearchAllTeams(t *testing.T) {
}
func TestSearchAllTeamsPaged(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
commonRandom := model.NewId()
@@ -2000,6 +2021,7 @@ func TestSearchAllTeamsPaged(t *testing.T) {
}
func TestSearchAllTeamsSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2070,6 +2092,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) {
}
func TestGetTeamsForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2112,6 +2135,7 @@ func TestGetTeamsForUser(t *testing.T) {
}
func TestGetTeamsForUserSanitization(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -2211,6 +2235,7 @@ func TestGetTeamsForUserSanitization(t *testing.T) {
}
func TestGetTeamMember(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2249,6 +2274,7 @@ func TestGetTeamMember(t *testing.T) {
}
func TestGetTeamMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2321,6 +2347,7 @@ func TestGetTeamMembers(t *testing.T) {
}
func TestGetTeamMembersForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2363,6 +2390,7 @@ func TestGetTeamMembersForUser(t *testing.T) {
}
func TestGetTeamMembersByIds(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2400,6 +2428,7 @@ func TestGetTeamMembersByIds(t *testing.T) {
}
func TestAddTeamMember(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2688,6 +2717,7 @@ func TestAddTeamMemberGuestPermissions(t *testing.T) {
}
func TestAddTeamMemberMyself(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -2778,6 +2808,7 @@ func TestAddTeamMemberMyself(t *testing.T) {
}
func TestAddTeamMembersDomainConstrained(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.SystemAdminClient
@@ -2838,6 +2869,7 @@ func TestAddTeamMembersDomainConstrained(t *testing.T) {
}
func TestAddTeamMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3037,6 +3069,7 @@ func TestAddTeamMembersGuestPermissions(t *testing.T) {
}
func TestRemoveTeamMember(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3104,6 +3137,7 @@ func TestRemoveTeamMember(t *testing.T) {
}
func TestRemoveTeamMemberEvents(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3138,6 +3172,7 @@ func TestRemoveTeamMemberEvents(t *testing.T) {
}
func TestGetTeamStats(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3189,6 +3224,7 @@ func TestGetTeamStats(t *testing.T) {
}
func TestUpdateTeamMemberRoles(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3268,6 +3304,7 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
}
func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
@@ -3410,6 +3447,7 @@ func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
}
func TestGetMyTeamsUnread(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3442,6 +3480,7 @@ func TestGetMyTeamsUnread(t *testing.T) {
}
func TestTeamExists(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -3538,6 +3577,7 @@ func TestTeamExists(t *testing.T) {
}
func TestImportTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3629,6 +3669,7 @@ func TestImportTeam(t *testing.T) {
}
func TestValidateUserPermissionsOnChannels(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3657,6 +3698,7 @@ func TestValidateUserPermissionsOnChannels(t *testing.T) {
}
func TestInviteUsersToTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3826,6 +3868,7 @@ func TestInviteUsersToTeam(t *testing.T) {
}
func TestInviteGuestsToTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -3971,6 +4014,7 @@ func TestInviteGuestsToTeam(t *testing.T) {
}
func TestInviteGuest(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
guest1 := th.GenerateTestEmail()
@@ -4017,6 +4061,7 @@ func TestInviteGuest(t *testing.T) {
}
func TestGetTeamInviteInfo(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4042,6 +4087,7 @@ func TestGetTeamInviteInfo(t *testing.T) {
}
func TestSetTeamIcon(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4100,6 +4146,7 @@ func TestSetTeamIcon(t *testing.T) {
}
func TestGetTeamIcon(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4119,6 +4166,7 @@ func TestGetTeamIcon(t *testing.T) {
}
func TestRemoveTeamIcon(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -4158,6 +4206,7 @@ func TestRemoveTeamIcon(t *testing.T) {
}
func TestUpdateTeamScheme(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -4238,6 +4287,7 @@ func TestUpdateTeamScheme(t *testing.T) {
}
func TestTeamMembersMinusGroupMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -4331,6 +4381,7 @@ func TestTeamMembersMinusGroupMembers(t *testing.T) {
}
func TestInvalidateAllEmailInvites(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -14,6 +14,7 @@ import (
)
func TestGetTermsOfService(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -31,6 +32,7 @@ func TestGetTermsOfService(t *testing.T) {
}
func TestCreateTermsOfService(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -40,6 +42,7 @@ func TestCreateTermsOfService(t *testing.T) {
}
func TestCreateTermsOfServiceAdminUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.SystemAdminClient

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

@@ -20,6 +20,7 @@ import (
)
func TestCreateUpload(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -119,6 +120,7 @@ func TestCreateUpload(t *testing.T) {
}
func TestGetUpload(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -163,6 +165,7 @@ func TestGetUpload(t *testing.T) {
}
func TestGetUploadsForUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -210,6 +213,7 @@ func TestGetUploadsForUser(t *testing.T) {
}
func TestUploadData(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
if *th.App.Config().FileSettings.DriverName == "" {
@@ -335,6 +339,7 @@ func TestUploadData(t *testing.T) {
}
func TestUploadDataMultipart(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
if *th.App.Config().FileSettings.DriverName == "" {

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

@@ -15,6 +15,7 @@ import (
)
func TestGetPostsUsage(t *testing.T) {
mainHelper.Parallel(t)
t.Run("unauthenticated users can not access", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -54,6 +55,7 @@ func TestGetPostsUsage(t *testing.T) {
}
func TestGetStorageUsage(t *testing.T) {
mainHelper.Parallel(t)
t.Run("unauthenticated users cannot access", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()
@@ -69,6 +71,7 @@ func TestGetStorageUsage(t *testing.T) {
}
func TestGetTeamsUsage(t *testing.T) {
mainHelper.Parallel(t)
t.Run("unauthenticated users can not access", func(t *testing.T) {
th := Setup(t)
defer th.TearDown()

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@@ -13,6 +13,7 @@ import (
)
func TestAPIRestrictedViewMembers(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()

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

@@ -14,6 +14,7 @@ import (
)
func TestCreateIncomingWebhook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -108,6 +109,7 @@ func TestCreateIncomingWebhook(t *testing.T) {
}
func TestCreateIncomingWebhook_BypassTeamPermissions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -145,6 +147,7 @@ func TestCreateIncomingWebhook_BypassTeamPermissions(t *testing.T) {
}
func TestGetIncomingWebhooks(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -223,6 +226,7 @@ func TestGetIncomingWebhooks(t *testing.T) {
}
func TestGetIncomingWebhooksListByUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
BasicClient := th.Client
@@ -258,7 +262,7 @@ func TestGetIncomingWebhooksListByUser(t *testing.T) {
assert.Equal(t, 2, len(adminHooks))
})
//Re-check basic user that has no MANAGE_OTHERS permission
// Re-check basic user that has no MANAGE_OTHERS permission
filteredHooks, _, err := BasicClient.GetIncomingWebhooks(context.Background(), 0, 1000, "")
require.NoError(t, err)
assert.Equal(t, 1, len(filteredHooks))
@@ -266,6 +270,7 @@ func TestGetIncomingWebhooksListByUser(t *testing.T) {
}
func TestGetIncomingWebhooksByTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
BasicClient := th.Client
@@ -300,7 +305,7 @@ func TestGetIncomingWebhooksByTeam(t *testing.T) {
assert.Equal(t, 2, len(adminHooks))
})
//Re-check basic user that has no MANAGE_OTHERS permission
// Re-check basic user that has no MANAGE_OTHERS permission
filteredHooks, _, err := BasicClient.GetIncomingWebhooksForTeam(context.Background(), th.BasicTeam.Id, 0, 1000, "")
require.NoError(t, err)
assert.Equal(t, 1, len(filteredHooks))
@@ -308,6 +313,7 @@ func TestGetIncomingWebhooksByTeam(t *testing.T) {
}
func TestGetIncomingWebhooksWithCount(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
BasicClient := th.Client
@@ -362,6 +368,7 @@ func TestGetIncomingWebhooksWithCount(t *testing.T) {
}
func TestGetIncomingWebhook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -398,13 +405,14 @@ func TestGetIncomingWebhook(t *testing.T) {
}
func TestDeleteIncomingWebhook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
//var rhook *model.IncomingWebhook
//var hook *model.IncomingWebhook
// var rhook *model.IncomingWebhook
// var hook *model.IncomingWebhook
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
resp, err := client.DeleteIncomingWebhook(context.Background(), "abc")
@@ -449,6 +457,7 @@ func TestDeleteIncomingWebhook(t *testing.T) {
}
func TestCreateOutgoingWebhook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -533,6 +542,7 @@ func TestCreateOutgoingWebhook(t *testing.T) {
}
func TestGetOutgoingWebhooks(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -632,6 +642,7 @@ func TestGetOutgoingWebhooks(t *testing.T) {
}
func TestGetOutgoingWebhooksByTeam(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -665,7 +676,7 @@ func TestGetOutgoingWebhooksByTeam(t *testing.T) {
assert.Equal(t, 2, len(adminHooks))
})
//Re-check basic user that has no MANAGE_OTHERS permission
// Re-check basic user that has no MANAGE_OTHERS permission
filteredHooks, _, err := th.Client.GetOutgoingWebhooksForTeam(context.Background(), th.BasicTeam.Id, 0, 1000, "")
require.NoError(t, err)
assert.Equal(t, 1, len(filteredHooks))
@@ -673,6 +684,7 @@ func TestGetOutgoingWebhooksByTeam(t *testing.T) {
}
func TestGetOutgoingWebhooksByChannel(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -706,7 +718,7 @@ func TestGetOutgoingWebhooksByChannel(t *testing.T) {
assert.Equal(t, 2, len(adminHooks))
})
//Re-check basic user that has no MANAGE_OTHERS permission
// Re-check basic user that has no MANAGE_OTHERS permission
filteredHooks, _, err := th.Client.GetOutgoingWebhooksForChannel(context.Background(), th.BasicChannel.Id, 0, 1000, "")
require.NoError(t, err)
assert.Equal(t, 1, len(filteredHooks))
@@ -714,6 +726,7 @@ func TestGetOutgoingWebhooksByChannel(t *testing.T) {
}
func TestGetOutgoingWebhooksListByUser(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
th.LoginBasic()
@@ -748,7 +761,7 @@ func TestGetOutgoingWebhooksListByUser(t *testing.T) {
assert.Equal(t, 2, len(adminHooks))
})
//Re-check basic user that has no MANAGE_OTHERS permission
// Re-check basic user that has no MANAGE_OTHERS permission
filteredHooks, _, err := th.Client.GetOutgoingWebhooks(context.Background(), 0, 1000, "")
require.NoError(t, err)
assert.Equal(t, 1, len(filteredHooks))
@@ -756,6 +769,7 @@ func TestGetOutgoingWebhooksListByUser(t *testing.T) {
}
func TestGetOutgoingWebhook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -791,6 +805,7 @@ func TestGetOutgoingWebhook(t *testing.T) {
}
func TestUpdateIncomingHook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -834,7 +849,7 @@ func TestUpdateIncomingHook(t *testing.T) {
require.Empty(t, updatedHook.Username, "Hook username was incorrectly updated")
require.Empty(t, updatedHook.IconURL, "Hook icon was incorrectly updated")
//updatedHook, _ = th.App.GetIncomingWebhook(createdHook.Id)
// updatedHook, _ = th.App.GetIncomingWebhook(createdHook.Id)
assert.Equal(t, updatedHook.ChannelId, createdHook.ChannelId)
}, "UpdateIncomingHook, overrides disabled")
@@ -862,7 +877,7 @@ func TestUpdateIncomingHook(t *testing.T) {
require.Exactly(t, "username", updatedHook.Username, "Hook username is not updated")
require.Exactly(t, "icon", updatedHook.IconURL, "Hook icon is not updated")
//updatedHook, _ = th.App.GetIncomingWebhook(createdHook.Id)
// updatedHook, _ = th.App.GetIncomingWebhook(createdHook.Id)
assert.Equal(t, updatedHook.ChannelId, createdHook.ChannelId)
}, "UpdateIncomingHook")
@@ -993,6 +1008,7 @@ func TestUpdateIncomingHook(t *testing.T) {
}
func TestUpdateIncomingWebhook_BypassTeamPermissions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1030,6 +1046,7 @@ func TestUpdateIncomingWebhook_BypassTeamPermissions(t *testing.T) {
}
func TestRegenOutgoingHookToken(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
@@ -1044,7 +1061,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
require.Error(t, err)
CheckBadRequestStatus(t, resp)
//investigate why is act weird on jenkins
// investigate why is act weird on jenkins
// _, resp,_ = th.SystemAdminClient.RegenOutgoingHookToken(context.Background(), "")
// CheckNotFoundStatus(t, resp)
@@ -1063,6 +1080,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
}
func TestUpdateOutgoingHook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1074,8 +1092,10 @@ func TestUpdateOutgoingHook(t *testing.T) {
th.AddPermissionToRole(model.PermissionManageOutgoingWebhooks.Id, model.TeamAdminRoleId)
th.RemovePermissionFromRole(model.PermissionManageOutgoingWebhooks.Id, model.TeamUserRoleId)
createdHook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"cats"}}
createdHook := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"cats"},
}
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
rcreatedHook, _, err := th.SystemAdminClient.CreateOutgoingWebhook(context.Background(), createdHook)
@@ -1112,8 +1132,10 @@ func TestUpdateOutgoingHook(t *testing.T) {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
hook2 := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats"}}
hook2 := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats"},
}
createdHook2, _, err := th.SystemAdminClient.CreateOutgoingWebhook(context.Background(), hook2)
require.NoError(t, err)
@@ -1145,8 +1167,10 @@ func TestUpdateOutgoingHook(t *testing.T) {
}, "ModifyUpdateAt")
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
nonExistentHook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats"}}
nonExistentHook := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats"},
}
_, resp, err := client.UpdateOutgoingWebhook(context.Background(), nonExistentHook)
require.Error(t, err)
@@ -1168,8 +1192,10 @@ func TestUpdateOutgoingHook(t *testing.T) {
})
th.AddPermissionToRole(model.PermissionManageOutgoingWebhooks.Id, model.TeamUserRoleId)
hook2 := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats2"}}
hook2 := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats2"},
}
createdHook2, _, err := th.SystemAdminClient.CreateOutgoingWebhook(context.Background(), hook2)
require.NoError(t, err)
@@ -1195,13 +1221,17 @@ func TestUpdateOutgoingHook(t *testing.T) {
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
firstHook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://someurl"}, TriggerWords: []string{"first"}}
firstHook := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://someurl"}, TriggerWords: []string{"first"},
}
firstHook, _, err = th.SystemAdminClient.CreateOutgoingWebhook(context.Background(), firstHook)
require.NoError(t, err)
baseHook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://someurl"}, TriggerWords: []string{"base"}}
baseHook := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://someurl"}, TriggerWords: []string{"base"},
}
baseHook, _, err = th.SystemAdminClient.CreateOutgoingWebhook(context.Background(), baseHook)
require.NoError(t, err)
@@ -1273,6 +1303,7 @@ func TestUpdateOutgoingHook(t *testing.T) {
}
func TestUpdateOutgoingWebhook_BypassTeamPermissions(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1284,8 +1315,10 @@ func TestUpdateOutgoingWebhook_BypassTeamPermissions(t *testing.T) {
th.AddPermissionToRole(model.PermissionManageOutgoingWebhooks.Id, model.TeamAdminRoleId)
th.AddPermissionToRole(model.PermissionManageOutgoingWebhooks.Id, model.TeamUserRoleId)
hook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats2"}}
hook := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats2"},
}
rhook, _, err := th.Client.CreateOutgoingWebhook(context.Background(), hook)
require.NoError(t, err)
@@ -1308,6 +1341,7 @@ func TestUpdateOutgoingWebhook_BypassTeamPermissions(t *testing.T) {
}
func TestDeleteOutgoingHook(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -1326,8 +1360,10 @@ func TestDeleteOutgoingHook(t *testing.T) {
}, "WhenHookDoesNotExist")
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
hook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"cats"}}
hook := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"cats"},
}
rhook, _, err := th.SystemAdminClient.CreateOutgoingWebhook(context.Background(), hook)
require.NoError(t, err)
@@ -1342,8 +1378,10 @@ func TestDeleteOutgoingHook(t *testing.T) {
}, "WhenHookExists")
t.Run("WhenUserDoesNotHavePermissions", func(t *testing.T) {
hook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"dogs"}}
hook := &model.OutgoingWebhook{
ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"dogs"},
}
rhook, _, err := th.SystemAdminClient.CreateOutgoingWebhook(context.Background(), hook)
require.NoError(t, err)

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

@@ -19,6 +19,7 @@ import (
// because the websocket client is known to be racy and needs a big overhaul
// to fix everything.
func TestWebSocket(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
WebSocketClient, err := th.CreateWebSocketClient()

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

@@ -21,6 +21,7 @@ import (
)
func TestWebSocketTrailingSlash(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -30,6 +31,7 @@ func TestWebSocketTrailingSlash(t *testing.T) {
}
func TestWebSocketEvent(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -95,6 +97,7 @@ func TestWebSocketEvent(t *testing.T) {
}
func TestCreateDirectChannelWithSocket(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -150,6 +153,7 @@ func TestCreateDirectChannelWithSocket(t *testing.T) {
}
func TestWebsocketOriginSecurity(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()
@@ -200,6 +204,7 @@ func TestWebsocketOriginSecurity(t *testing.T) {
}
func TestWebSocketReconnectRace(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -234,6 +239,7 @@ func TestWebSocketReconnectRace(t *testing.T) {
}
func TestWebSocketSendBinary(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -273,6 +279,7 @@ func TestWebSocketSendBinary(t *testing.T) {
}
func TestWebSocketStatuses(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -412,6 +419,7 @@ func TestWebSocketStatuses(t *testing.T) {
}
func TestWebSocketPresence(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t).InitBasic()
defer th.TearDown()
@@ -442,6 +450,7 @@ func TestWebSocketPresence(t *testing.T) {
}
func TestWebSocketUpgrade(t *testing.T) {
mainHelper.Parallel(t)
th := Setup(t)
defer th.TearDown()