mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
disable playbooks for more unit tests
This commit is contained in:
@@ -71,9 +71,10 @@ type TestHelper struct {
|
||||
|
||||
IncludeCacheLayer bool
|
||||
|
||||
LogBuffer *mlog.Buffer
|
||||
TestLogger *mlog.Logger
|
||||
boardsProductEnvValue string
|
||||
LogBuffer *mlog.Buffer
|
||||
TestLogger *mlog.Logger
|
||||
boardsProductEnvValue string
|
||||
playbooksDisableEnvValue string
|
||||
}
|
||||
|
||||
var mainHelper *testlib.MainHelper
|
||||
@@ -316,6 +317,11 @@ func SetupConfigWithStoreMock(tb testing.TB, updateConfig func(cfg *model.Config
|
||||
}
|
||||
|
||||
func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
// disable Playbooks (temporarily) as it causes many more mocked methods to get
|
||||
// called, and cannot receieve a mocked database. Boards is already disabled here.
|
||||
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
|
||||
|
||||
th := setupTestHelper(testlib.GetMockStoreForSetupFunctions(), nil, false, false, nil, nil)
|
||||
statusMock := mocks.StatusStore{}
|
||||
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
|
||||
@@ -326,6 +332,8 @@ func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
emptyMockStore.On("Close").Return(nil)
|
||||
emptyMockStore.On("Status").Return(&statusMock)
|
||||
th.App.Srv().SetStore(&emptyMockStore)
|
||||
|
||||
th.playbooksDisableEnvValue = playbooksDisableEnvValue
|
||||
return th
|
||||
}
|
||||
|
||||
@@ -379,11 +387,17 @@ func (th *TestHelper) ShutdownApp() {
|
||||
}
|
||||
|
||||
func (th *TestHelper) TearDown() {
|
||||
// reset board product setting to original
|
||||
// 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()
|
||||
|
||||
@@ -49,7 +49,8 @@ type TestHelper struct {
|
||||
|
||||
TestLogger *mlog.Logger
|
||||
|
||||
boardsProductEnvValue string
|
||||
boardsProductEnvValue string
|
||||
playbooksDisableEnvValue string
|
||||
}
|
||||
|
||||
func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
@@ -57,10 +58,17 @@ func SetupWithStoreMock(tb testing.TB) *TestHelper {
|
||||
tb.SkipNow()
|
||||
}
|
||||
|
||||
// disable Playbooks (temporarily) as it causes many more mocked methods to get
|
||||
// called, and cannot receieve a mocked database. Boards is already disabled here.
|
||||
playbooksDisableEnvValue := os.Getenv("MM_DISABLE_PLAYBOOKS")
|
||||
os.Setenv("MM_DISABLE_PLAYBOOKS", "true")
|
||||
|
||||
th := setupTestHelper(tb, false)
|
||||
emptyMockStore := mocks.Store{}
|
||||
emptyMockStore.On("Close").Return(nil)
|
||||
th.App.Srv().SetStore(&emptyMockStore)
|
||||
|
||||
th.playbooksDisableEnvValue = playbooksDisableEnvValue
|
||||
return th
|
||||
}
|
||||
|
||||
@@ -187,11 +195,17 @@ func (th *TestHelper) InitBasic() *TestHelper {
|
||||
}
|
||||
|
||||
func (th *TestHelper) TearDown() {
|
||||
// reset board product setting to original
|
||||
// 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()
|
||||
|
||||
Reference in New Issue
Block a user