Skip to content

Commit

Permalink
re-enable products
Browse files Browse the repository at this point in the history
  • Loading branch information
isacikgoz committed Mar 22, 2023
1 parent 1f63b7b commit 15c09ac
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 136 deletions.
43 changes: 9 additions & 34 deletions server/channels/api4/apitestlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down
39 changes: 7 additions & 32 deletions server/channels/app/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{}
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down
39 changes: 7 additions & 32 deletions server/channels/app/slashcommands/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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()
Expand Down
38 changes: 6 additions & 32 deletions server/channels/web/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ type TestHelper struct {
IncludeCacheLayer bool

TestLogger *mlog.Logger

boardsProductEnvValue string
playbooksDisableEnvValue string
}

func SetupWithStoreMock(tb testing.TB) *TestHelper {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down
6 changes: 0 additions & 6 deletions server/playbooks/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 15c09ac

Please sign in to comment.