From 15c09ac22b0d307390e9a5193d1bde934e87a1b1 Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Wed, 22 Mar 2023 14:22:19 +0300 Subject: [PATCH] re-enable products --- server/channels/api4/apitestlib.go | 43 ++++--------------- server/channels/app/helper_test.go | 39 +++-------------- .../channels/app/slashcommands/helper_test.go | 39 +++-------------- server/channels/web/web_test.go | 38 +++------------- server/playbooks/server/main_test.go | 6 --- 5 files changed, 29 insertions(+), 136 deletions(-) diff --git a/server/channels/api4/apitestlib.go b/server/channels/api4/apitestlib.go index 92ef4a9221..a9a8d61c3e 100644 --- a/server/channels/api4/apitestlib.go +++ b/server/channels/api4/apitestlib.go @@ -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 @@ -105,16 +103,6 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent *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 +141,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 +372,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() diff --git a/server/channels/app/helper_test.go b/server/channels/app/helper_test.go index 4b5cf1aa0b..229ad2cee3 100644 --- a/server/channels/app/helper_test.go +++ b/server/channels/app/helper_test.go @@ -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 { @@ -63,16 +61,6 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo *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 +91,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) @@ -553,17 +539,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() diff --git a/server/channels/app/slashcommands/helper_test.go b/server/channels/app/slashcommands/helper_test.go index cc0960cee6..f4aed12d2c 100644 --- a/server/channels/app/slashcommands/helper_test.go +++ b/server/channels/app/slashcommands/helper_test.go @@ -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 { @@ -54,16 +52,6 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo 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 +83,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 +375,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() diff --git a/server/channels/web/web_test.go b/server/channels/web/web_test.go index 704c2dd0c7..0ced5ffe7e 100644 --- a/server/channels/web/web_test.go +++ b/server/channels/web/web_test.go @@ -48,9 +48,6 @@ type TestHelper struct { IncludeCacheLayer bool TestLogger *mlog.Logger - - boardsProductEnvValue string - playbooksDisableEnvValue string } func SetupWithStoreMock(tb testing.TB) *TestHelper { @@ -81,16 +78,6 @@ func setupTestHelper(tb testing.TB, includeCacheLayer bool) *TestHelper { *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 +135,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 +179,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() diff --git a/server/playbooks/server/main_test.go b/server/playbooks/server/main_test.go index c0202a5c3e..f23e794d2f 100644 --- a/server/playbooks/server/main_test.go +++ b/server/playbooks/server/main_test.go @@ -120,11 +120,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 { @@ -164,7 +159,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{