* Revert "fix store issue take two"

This reverts commit 59f943c2c7ff7d88f7b36cc29e242042746e959e.

* Revert "fix store override issue"

This reverts commit 29c346757aa627c07d357c54991f9188c927dd1a.

* Revert "Fix TestPushNotificationRace"

This reverts commit 6d62dddf8679e82b02e8ad9fe7513217eef5b4ee.

* Revert "fix default DSN for CI"

This reverts commit e0e69cdbb0645bb50434f6b5bbd12bead1e7ce1d.

* Revert "disable playbooks from more unit tests"

This reverts commit a1e97a9e96bdd16537f5b6dbdc8335762617a9e0.

* Revert "disable playbooks for more tests"

This reverts commit 4d2dc74f05339f0b3cd28b997a2e35ae20f898be.

* Revert "disable playbooks for TestSAMLSettings"

This reverts commit 35c1a4312d0c6a0a64991520fa5b0892c083e6a1.

* Revert "disable playbooks for more unit tests"

This reverts commit c049631a1474cddf168b2be8feb24140e0dcfd48.

* Revert "disable playbooks for mocked enterprise tests"

This reverts commit 829317fddbd0e84866534a5a75e52dcffd2dbde7.

* Partially revert "disable playbooks for channel/apps mocked tests"

This reverts commit 52b4a0a6cf135d26f53298294ed23734aafae0d2.

* Revert "fix TestUnitUpdateConfig"

This reverts commit 8f134f2a8ae9765aa2b6f66d6827e10ef1f5109f.

* Revert "add plugin mock to TestUnitUpdateConfig"

This reverts commit 3ec5419092135f494fd04701b5cbbd15920e667b.

* Revert "disable Boards for more test helpers"

This reverts commit 5d4d0d02d9cf6f872f0304098c68a01a3aab0fbe.

* Revert "disable boards at correct place in test helpers"

This reverts commit 0c9e175f79293c8be4289c7424930388f207dc75.

* Partially revert "disable boards for slash cmd tests"

This reverts commit fad8d9de93f5ce351d2e50fd6448662e75f597ae.

* Revert "disable Boards for channels web tests"

This reverts commit 15540fdfc09cf927071af718d4ad0b2c58308328.

* Revert "Adds a teardown function to playbook server tests to disable and reenable boards"

This reverts commit 9a46e3d0f43f66d548994986b8c4029d58ad022f.

* Revert "Test disable boards through feature flag"

This reverts commit 787044add8ba8e2680a2c3c6ba11e709cebc8705.

* TestUnitUpdateConfig: restore callback check

* Revert "Revert "fix default DSN for CI""

This reverts commit 01b879d55ad1249265f23c6fd9ceb5d7730ddb3d.
Этот коммит содержится в:
Jesse Hallam
2023-03-27 13:19:29 -03:00
коммит произвёл GitHub
родитель d62244aebb
Коммит 80c1431983
18 изменённых файлов: 113 добавлений и 259 удалений

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

@@ -71,10 +71,8 @@ type TestHelper struct {
IncludeCacheLayer bool
LogBuffer *mlog.Buffer
TestLogger *mlog.Logger
boardsProductEnvValue string
playbooksDisableEnvValue string
LogBuffer *mlog.Buffer
TestLogger *mlog.Logger
}
var mainHelper *testlib.MainHelper
@@ -104,17 +102,6 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
// disable Boards through the feature flag
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
memoryConfig.FeatureFlags.BoardsProduct = false
// disable Playbooks (temporarily) as it causes many more mocked methods to get
// called, and cannot receieve a mocked database.
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
if updateConfig != nil {
updateConfig(memoryConfig)
}
@@ -153,15 +140,13 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
}
th := &TestHelper{
App: app.New(app.ServerConnector(s.Channels())),
Server: s,
ConfigStore: configStore,
IncludeCacheLayer: includeCache,
Context: request.EmptyContext(testLogger),
TestLogger: testLogger,
LogBuffer: buffer,
boardsProductEnvValue: boardsProductEnvValue,
playbooksDisableEnvValue: playbooksDisableEnvValue,
App: app.New(app.ServerConnector(s.Channels())),
Server: s,
ConfigStore: configStore,
IncludeCacheLayer: includeCache,
Context: request.EmptyContext(testLogger),
TestLogger: testLogger,
LogBuffer: buffer,
}
th.Context.SetLogger(testLogger)
@@ -386,17 +371,6 @@ func (th *TestHelper) ShutdownApp() {
}
func (th *TestHelper) TearDown() {
// reset board and playbooks product setting to original
if th.boardsProductEnvValue != "" {
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
}
if th.playbooksDisableEnvValue != "" {
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
} else {
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
}
if th.IncludeCacheLayer {
// Clean all the caches
th.App.Srv().InvalidateAllCaches()

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

@@ -11,8 +11,10 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/server/channels/store/storetest/mocks"
)
/* Temporarily comment out until MM-11108
@@ -37,9 +39,26 @@ func init() {
}
func TestUnitUpdateConfig(t *testing.T) {
th := Setup(t)
th := SetupWithStoreMock(t)
defer th.TearDown()
mockStore := th.App.Srv().Store().(*mocks.Store)
mockUserStore := mocks.UserStore{}
mockUserStore.On("Count", mock.Anything).Return(int64(10), nil)
mockPostStore := mocks.PostStore{}
mockPostStore.On("GetMaxPostSize").Return(65535, nil)
mockSystemStore := mocks.SystemStore{}
mockSystemStore.On("GetByName", "UpgradedFromTE").Return(&model.System{Name: "UpgradedFromTE", Value: "false"}, nil)
mockSystemStore.On("GetByName", "InstallationDate").Return(&model.System{Name: "InstallationDate", Value: "10"}, nil)
mockSystemStore.On("GetByName", "FirstServerRunTimestamp").Return(&model.System{Name: "FirstServerRunTimestamp", Value: "10"}, nil)
mockLicenseStore := mocks.LicenseStore{}
mockLicenseStore.On("Get", "").Return(&model.LicenseRecord{}, nil)
mockStore.On("User").Return(&mockUserStore)
mockStore.On("Post").Return(&mockPostStore)
mockStore.On("System").Return(&mockSystemStore)
mockStore.On("License").Return(&mockLicenseStore)
mockStore.On("GetDBSchemaVersion").Return(1, nil)
prev := *th.App.Config().ServiceSettings.SiteURL
var called int32

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

@@ -42,9 +42,7 @@ type TestHelper struct {
TestLogger *mlog.Logger
IncludeCacheLayer bool
tempWorkspace string
boardsProductEnvValue string
playbooksDisableEnvValue string
tempWorkspace string
}
func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer bool, options []Option, tb testing.TB) *TestHelper {
@@ -62,17 +60,6 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
*memoryConfig.LogSettings.EnableSentry = false // disable error reporting during tests
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
// disable Boards through the feature flag
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
memoryConfig.FeatureFlags.BoardsProduct = false
// disable Playbooks (temporarily) as it causes many more mocked methods to get
// called, and cannot receieve a mocked database.
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
configStore.Set(memoryConfig)
buffer := &mlog.Buffer{}
@@ -103,14 +90,12 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
}
th := &TestHelper{
App: New(ServerConnector(s.Channels())),
Context: request.EmptyContext(testLogger),
Server: s,
LogBuffer: buffer,
TestLogger: testLogger,
IncludeCacheLayer: includeCacheLayer,
boardsProductEnvValue: boardsProductEnvValue,
playbooksDisableEnvValue: playbooksDisableEnvValue,
App: New(ServerConnector(s.Channels())),
Context: request.EmptyContext(testLogger),
Server: s,
LogBuffer: buffer,
TestLogger: testLogger,
IncludeCacheLayer: includeCacheLayer,
}
th.Context.SetLogger(testLogger)
@@ -184,10 +169,16 @@ func SetupWithStoreMock(tb testing.TB) *TestHelper {
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
statusMock.On("UpdateLastActivityAt", "user1", mock.Anything).Return(nil)
statusMock.On("SaveOrUpdate", mock.AnythingOfType("*model.Status")).Return(nil)
pluginMock := mocks.PluginStore{}
pluginMock.On("Get", mock.AnythingOfType("string"), mock.AnythingOfType("string")).Return(&model.PluginKeyValue{}, nil)
emptyMockStore := mocks.Store{}
emptyMockStore.On("Close").Return(nil)
emptyMockStore.On("Status").Return(&statusMock)
emptyMockStore.On("Plugin").Return(&pluginMock).Maybe()
th.App.Srv().SetStore(&emptyMockStore)
return th
}
@@ -553,17 +544,6 @@ func (th *TestHelper) ShutdownApp() {
}
func (th *TestHelper) TearDown() {
// reset board and playbooks product setting to original
if th.boardsProductEnvValue != "" {
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
}
if th.playbooksDisableEnvValue != "" {
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
} else {
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
}
if th.IncludeCacheLayer {
// Clean all the caches
th.App.Srv().InvalidateAllCaches()

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

@@ -1445,13 +1445,9 @@ func TestPushNotificationRace(t *testing.T) {
Router: mux.NewRouter(),
}
var err error
s.platform, err = platform.New(
platform.ServiceConfig{
ConfigStore: memoryStore,
},
platform.SetFileStore(&fmocks.FileBackend{}),
platform.StoreOverride(th.GetSqlStore()),
)
s.platform, err = platform.New(platform.ServiceConfig{
ConfigStore: memoryStore,
}, platform.SetFileStore(&fmocks.FileBackend{}))
s.SetStore(mockStore)
require.NoError(t, err)
serviceMap := map[product.ServiceKey]any{

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

@@ -73,17 +73,15 @@ func (s *Server) initializeProducts(
func (s *Server) shouldStart(product string) bool {
if product == "boards" {
if !s.Config().FeatureFlags.BoardsProduct {
s.Log().Info("Skipping Boards init; disabled via feature flag")
s.Log().Warn("Skipping boards start: not enabled via feature flag")
return false
}
s.Log().Info("Allowing Boards init; enabled via feature flag")
}
if product == "playbooks" {
if os.Getenv("MM_DISABLE_PLAYBOOKS") == "true" {
s.Log().Info("Skipping Playbooks init; disabled via env var")
s.Log().Warn("Skipping playbooks start: disabled via env var")
return false
}
s.Log().Info("Allowing Playbooks init; enabled via env var")
}
return true

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

@@ -36,9 +36,7 @@ type TestHelper struct {
TestLogger *mlog.Logger
IncludeCacheLayer bool
tempWorkspace string
boardsProductEnvValue string
playbooksDisableEnvValue string
tempWorkspace string
}
func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer bool, tb testing.TB, configSet func(*model.Config)) *TestHelper {
@@ -53,17 +51,6 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
if configSet != nil {
configSet(memoryConfig)
}
// disable Boards through the feature flag
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
memoryConfig.FeatureFlags.BoardsProduct = false
// disable Playbooks (temporarily) as it causes many more mocked methods to get
// called, and cannot receieve a mocked database.
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
*memoryConfig.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins")
*memoryConfig.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp")
*memoryConfig.PluginSettings.AutomaticPrepackagedPlugins = false
@@ -95,14 +82,12 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
}
th := &TestHelper{
App: app.New(app.ServerConnector(s.Channels())),
Context: request.EmptyContext(testLogger),
Server: s,
LogBuffer: buffer,
TestLogger: testLogger,
IncludeCacheLayer: includeCacheLayer,
boardsProductEnvValue: boardsProductEnvValue,
playbooksDisableEnvValue: playbooksDisableEnvValue,
App: app.New(app.ServerConnector(s.Channels())),
Context: request.EmptyContext(testLogger),
Server: s,
LogBuffer: buffer,
TestLogger: testLogger,
IncludeCacheLayer: includeCacheLayer,
}
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxUsersPerTeam = 50 })
@@ -389,17 +374,6 @@ func (th *TestHelper) shutdownApp() {
}
func (th *TestHelper) tearDown() {
// reset board and playbooks product setting to original
if th.boardsProductEnvValue != "" {
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
}
if th.playbooksDisableEnvValue != "" {
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
} else {
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
}
if th.IncludeCacheLayer {
// Clean all the caches
th.App.Srv().InvalidateAllCaches()

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

@@ -48,9 +48,6 @@ type TestHelper struct {
IncludeCacheLayer bool
TestLogger *mlog.Logger
boardsProductEnvValue string
playbooksDisableEnvValue string
}
func SetupWithStoreMock(tb testing.TB) *TestHelper {
@@ -80,17 +77,6 @@ func setupTestHelper(tb testing.TB, includeCacheLayer bool) *TestHelper {
*newConfig.AnnouncementSettings.AdminNoticesEnabled = false
*newConfig.AnnouncementSettings.UserNoticesEnabled = false
*newConfig.PluginSettings.AutomaticPrepackagedPlugins = false
// disable Boards through the feature flag
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
newConfig.FeatureFlags.BoardsProduct = false
// disable Playbooks (temporarily) as it causes many more mocked methods to get
// called, and cannot receieve a mocked database.
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
memoryStore.Set(newConfig)
var options []app.Option
options = append(options, app.ConfigStore(memoryStore))
@@ -148,14 +134,12 @@ func setupTestHelper(tb testing.TB, includeCacheLayer bool) *TestHelper {
})
th := &TestHelper{
App: a,
Context: request.EmptyContext(testLogger),
Server: s,
Web: web,
IncludeCacheLayer: includeCacheLayer,
TestLogger: testLogger,
boardsProductEnvValue: boardsProductEnvValue,
playbooksDisableEnvValue: playbooksDisableEnvValue,
App: a,
Context: request.EmptyContext(testLogger),
Server: s,
Web: web,
IncludeCacheLayer: includeCacheLayer,
TestLogger: testLogger,
}
th.Context.SetLogger(testLogger)
@@ -194,17 +178,6 @@ func (th *TestHelper) InitBasic() *TestHelper {
}
func (th *TestHelper) TearDown() {
// reset board and playbooks product setting to original
if th.boardsProductEnvValue != "" {
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", th.boardsProductEnvValue)
}
if th.playbooksDisableEnvValue != "" {
os.Setenv("MM_DISABLE_PLAYBOOKS", th.playbooksDisableEnvValue)
} else {
os.Unsetenv("MM_DISABLE_PLAYBOOKS")
}
if th.IncludeCacheLayer {
// Clean all the caches
th.App.Srv().InvalidateAllCaches()

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

@@ -15,8 +15,7 @@ import (
)
func TestActionCreation(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
createNewChannel := func(t *testing.T, name string) *model.Channel {
@@ -201,8 +200,7 @@ func TestActionCreation(t *testing.T) {
}
func TestActionList(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
// Create three valid actions
@@ -294,8 +292,7 @@ func TestActionList(t *testing.T) {
}
func TestActionUpdate(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
// Create a valid action

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

@@ -16,8 +16,7 @@ func TestTrialLicences(t *testing.T) {
// This test is flaky due to upstream connectivity issues.
t.Skip()
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("request trial license without permissions", func(t *testing.T) {

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

@@ -11,8 +11,7 @@ import (
)
func TestAPI(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
t.Run("404", func(t *testing.T) {

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

@@ -21,8 +21,7 @@ import (
)
func TestGraphQLPlaybooks(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("basic get", func(t *testing.T) {
@@ -206,8 +205,7 @@ func TestGraphQLPlaybooks(t *testing.T) {
}
func TestGraphQLUpdatePlaybookFails(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("update playbook fails because size constraints.", func(t *testing.T) {
@@ -370,8 +368,7 @@ func TestGraphQLUpdatePlaybookFails(t *testing.T) {
}
func TestUpdatePlaybookFavorite(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("favorite", func(t *testing.T) {
@@ -493,8 +490,7 @@ func gqlTestPlaybookUpdate(e *TestEnvironment, t *testing.T, playbookID string,
}
func TestGraphQLPlaybooksMetrics(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("metrics get", func(t *testing.T) {

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

@@ -20,8 +20,7 @@ import (
)
func TestGraphQLRunList(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("list by participantOrFollower", func(t *testing.T) {
@@ -206,8 +205,7 @@ func TestGraphQLRunList(t *testing.T) {
}
func TestGraphQLChangeRunParticipants(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
user3, _, err := e.ServerAdminClient.CreateUser(&model.User{
@@ -669,8 +667,7 @@ func TestGraphQLChangeRunParticipants(t *testing.T) {
}
func TestGraphQLChangeRunOwner(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
// create a third user to test change owner
@@ -713,8 +710,7 @@ func TestGraphQLChangeRunOwner(t *testing.T) {
}
func TestSetRunFavorite(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
createRun := func() *client.PlaybookRun {
@@ -800,8 +796,7 @@ func TestSetRunFavorite(t *testing.T) {
}
func TestResolverFavorites(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
createRun := func() *client.PlaybookRun {
@@ -833,8 +828,7 @@ func TestResolverFavorites(t *testing.T) {
}
func TestResolverPlaybooks(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
createRun := func() *client.PlaybookRun {
@@ -860,8 +854,7 @@ func TestResolverPlaybooks(t *testing.T) {
}
func TestUpdateRun(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
createRun := func() *client.PlaybookRun {
@@ -977,8 +970,7 @@ func TestUpdateRun(t *testing.T) {
}
func TestUpdateRunTaskActions(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("task actions mutation create and update", func(t *testing.T) {
@@ -1071,8 +1063,7 @@ func TestUpdateRunTaskActions(t *testing.T) {
}
func TestBadGraphQLRequest(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
testRunsQuery := `

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

@@ -22,8 +22,7 @@ import (
)
func TestPlaybooks(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
e.CreateBasicServer()
@@ -267,8 +266,7 @@ func TestPlaybooks(t *testing.T) {
}
func TestCreateInvalidPlaybook(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
e.CreateBasicServer()
@@ -369,8 +367,7 @@ func TestCreateInvalidPlaybook(t *testing.T) {
}
func TestPlaybooksRetrieval(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("get playbook", func(t *testing.T) {
@@ -387,8 +384,7 @@ func TestPlaybooksRetrieval(t *testing.T) {
}
func TestPlaybookUpdate(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("update playbook properties", func(t *testing.T) {
@@ -521,8 +517,7 @@ func TestPlaybookUpdate(t *testing.T) {
}
func TestPlaybookUpdateCrossTeam(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("update playbook properties not in team public playbook", func(t *testing.T) {
@@ -552,8 +547,7 @@ func TestPlaybookUpdateCrossTeam(t *testing.T) {
}
func TestPlaybooksSort(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
e.CreateBasicServer()
e.SetE20Licence()
@@ -795,8 +789,7 @@ func TestPlaybooksSort(t *testing.T) {
}
func TestPlaybooksPaging(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
e.CreateBasicServer()
e.SetE20Licence()
@@ -935,8 +928,7 @@ func getPlaybookIDsList(playbooks []client.Playbook) []string {
}
func TestPlaybooksPermissions(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("test no permissions to create", func(t *testing.T) {
@@ -1148,8 +1140,7 @@ func TestPlaybooksPermissions(t *testing.T) {
}
func TestPlaybooksConversions(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("public to private conversion", func(t *testing.T) {
@@ -1208,8 +1199,7 @@ func TestPlaybooksConversions(t *testing.T) {
}
func TestPlaybooksImportExport(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
e.CreateBasicServer()
e.CreateBasicPublicPlaybook()
@@ -1237,8 +1227,7 @@ func TestPlaybooksImportExport(t *testing.T) {
}
func TestPlaybooksDuplicate(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
e.CreateBasicServer()
e.SetE20Licence()
@@ -1259,8 +1248,7 @@ func TestPlaybooksDuplicate(t *testing.T) {
}
func TestAddPostToTimeline(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
dialogRequest := model.SubmitDialogRequest{
@@ -1307,8 +1295,7 @@ func TestAddPostToTimeline(t *testing.T) {
}
func TestPlaybookStats(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateClients()
e.CreateBasicServer()
e.SetE20Licence()
@@ -1343,8 +1330,7 @@ func TestPlaybookStats(t *testing.T) {
}
func TestPlaybookGetAutoFollows(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
p1ID, err := e.PlaybooksAdminClient.Playbooks.Create(context.Background(), client.PlaybookCreateOptions{
@@ -1450,8 +1436,7 @@ func TestPlaybookGetAutoFollows(t *testing.T) {
}
func TestPlaybookChecklistCleanup(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("update playbook", func(t *testing.T) {

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

@@ -19,8 +19,7 @@ import (
)
func TestRunCreation(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
incompletePlaybookID, err := e.PlaybooksAdminClient.Playbooks.Create(context.Background(), client.PlaybookCreateOptions{
@@ -314,8 +313,7 @@ func TestRunCreation(t *testing.T) {
}
func TestCreateRunInExistingChannel(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
// create playbook
@@ -410,8 +408,7 @@ func TestCreateRunInExistingChannel(t *testing.T) {
}
func TestCreateInvalidRuns(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("fails if description is longer than 4096", func(t *testing.T) {
@@ -428,8 +425,7 @@ func TestCreateInvalidRuns(t *testing.T) {
}
func TestRunRetrieval(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("by channel id", func(t *testing.T) {
@@ -510,8 +506,7 @@ func TestRunRetrieval(t *testing.T) {
}
func TestRunPostStatusUpdate(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("post an update", func(t *testing.T) {
@@ -571,8 +566,7 @@ func TestRunPostStatusUpdate(t *testing.T) {
}
func TestChecklistManagement(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
createNewRunWithNoChecklists := func(t *testing.T) *client.PlaybookRun {
@@ -1188,8 +1182,7 @@ func TestChecklistManagement(t *testing.T) {
}
func TestChecklisFailTooLarge(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("checklist creation - failure: too large checklist", func(t *testing.T) {
@@ -1213,8 +1206,7 @@ func TestChecklisFailTooLarge(t *testing.T) {
}
func TestRunGetStatusUpdates(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("public - get no updates", func(t *testing.T) {
@@ -1343,8 +1335,7 @@ func TestRunGetStatusUpdates(t *testing.T) {
}
func TestRequestUpdate(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("private - no viewer access ", func(t *testing.T) {
@@ -1437,8 +1428,7 @@ func TestRequestUpdate(t *testing.T) {
}
func TestReminderReset(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("reminder reset - timeline event created", func(t *testing.T) {
@@ -1485,8 +1475,7 @@ func TestReminderReset(t *testing.T) {
}
func TestChecklisItem_SetAssignee(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
addSimpleChecklistToTun := func(t *testing.T, runID string) *client.PlaybookRun {
@@ -1597,8 +1586,7 @@ func TestChecklisItem_SetAssignee(t *testing.T) {
}
func TestChecklisItem_SetCommand(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
run, err := e.PlaybooksClient.PlaybookRuns.Create(context.Background(), client.PlaybookRunCreateOptions{
@@ -1699,8 +1687,7 @@ func TestChecklisItem_SetCommand(t *testing.T) {
}
func TestGetOwners(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
ownerFromUser := func(u *model.User) client.OwnerInfo {

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

@@ -14,8 +14,7 @@ import (
)
func TestSettings(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("get settings", func(t *testing.T) {

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

@@ -16,8 +16,7 @@ import (
)
func TestGetSiteStats(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("get sites stats", func(t *testing.T) {
@@ -50,8 +49,7 @@ func TestGetSiteStats(t *testing.T) {
}
func TestPlaybookKeyMetricsStats(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("3 runs with published metrics, 2 runs without publishing", func(t *testing.T) {

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

@@ -11,8 +11,7 @@ import (
)
func TestCreateEvent(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
t.Run("create an event with bad type fails", func(t *testing.T) {

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

@@ -97,7 +97,7 @@ func getEnvWithDefault(name, defaultValue string) string {
return defaultValue
}
func Setup(t *testing.T) (*TestEnvironment, func()) {
func Setup(t *testing.T) *TestEnvironment {
// Ignore any locally defined SiteURL as we intend to host our own.
os.Unsetenv("MM_SERVICESETTINGS_SITEURL")
os.Unsetenv("MM_SERVICESETTINGS_LISTENADDRESS")
@@ -126,11 +126,6 @@ func Setup(t *testing.T) (*TestEnvironment, func()) {
config.LogSettings.EnableFile = model.NewBool(false)
config.LogSettings.ConsoleLevel = model.NewString("INFO")
// disable Boards through the feature flag
boardsProductEnvValue := os.Getenv("MM_FEATUREFLAGS_BoardsProduct")
os.Unsetenv("MM_FEATUREFLAGS_BoardsProduct")
config.FeatureFlags.BoardsProduct = false
// override config with e2etest.config.json if it exists
textConfig, err := os.ReadFile("./e2etest.config.json")
if err == nil {
@@ -169,10 +164,6 @@ func Setup(t *testing.T) (*TestEnvironment, func()) {
ap := sapp.New(sapp.ServerConnector(server.Channels()))
teardown := func() {
os.Setenv("MM_FEATUREFLAGS_BoardsProduct", boardsProductEnvValue)
}
return &TestEnvironment{
T: t,
Srv: server,
@@ -184,7 +175,7 @@ func Setup(t *testing.T) (*TestEnvironment, func()) {
},
},
logger: testLogger,
}, teardown
}
}
func (e *TestEnvironment) CreateClients() {
@@ -478,8 +469,7 @@ func (e *TestEnvironment) CreateBasic() {
// TestTestFramework If this is failing you know the break is not exclusively in your test.
func TestTestFramework(t *testing.T) {
e, teardown := Setup(t)
defer teardown()
e := Setup(t)
e.CreateBasic()
}