disable playbooks for more unit tests

This commit is contained in:
wiggin77
2023-03-20 20:52:32 -04:00
parent 52b4a0a6cf
commit c049631a14
2 changed files with 34 additions and 6 deletions

View File

@@ -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()

View File

@@ -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()