* Enable products for channels tests

* increase unit test timeout; check IsConfigReadOnly

* make app-layers

* Avoid loading boards tempaltes between tests to improve speed

* Fix delete query to be compatible with both databases

* Avoid preserving the templates for boards store tests

* Run all tests in one command

* Revert "Run all tests in one command"

This reverts commit 0330f7cd8f96b47776770e8f80ba6ba18d98b8d1.

* concurrent pkg group tests in CI

* Revert "Revert "Run all tests in one command""

This reverts commit 73892fec772575ff054a99ba9e00a7b57ca74164.

* Revert "concurrent pkg group tests in CI"

This reverts commit 550fb6cdd4a7f14d9632f2626bc66f389173b5d9.

* try testing 3 subsets of packages concurrently to improve time taken

* Revert "try testing 3 subsets of packages concurrently to improve time taken"

This reverts commit 97475f3c4eafa8bbe047097e0841220884f68cdc.

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: wiggin77 <wiggin77@warpmail.net>
Этот коммит содержится в:
Miguel de la Cruz
2023-04-18 13:58:33 +02:00
коммит произвёл GitHub
родитель a8d79ec3da
Коммит 067e36c23c
43 изменённых файлов: 377 добавлений и 105 удалений

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

@@ -93,7 +93,9 @@ func setupTestHelper(dbStore store.Store, searchEngine *searchengine.Broker, ent
panic("failed to initialize memory store: " + err.Error())
}
memoryConfig := &model.Config{}
memoryConfig := &model.Config{
SqlSettings: *mainHelper.GetSQLSettings(),
}
memoryConfig.SetDefaults()
*memoryConfig.PluginSettings.Directory = filepath.Join(tempWorkspace, "plugins")
*memoryConfig.PluginSettings.ClientDirectory = filepath.Join(tempWorkspace, "webapp")
@@ -287,6 +289,7 @@ func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelpe
dbStore := mainHelper.GetStore()
dbStore.DropAllTables()
dbStore.MarkSystemRanUnitTests()
mainHelper.PreloadBoardsMigrationsIfNeeded()
searchEngine := mainHelper.GetSearchEngine()
th := setupTestHelper(dbStore, searchEngine, false, true, updateConfig, nil)
th.InitLogin()
@@ -294,7 +297,8 @@ func SetupConfig(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelpe
}
func SetupConfigWithStoreMock(tb testing.TB, updateConfig func(cfg *model.Config)) *TestHelper {
th := setupTestHelper(testlib.GetMockStoreForSetupFunctions(), nil, false, false, updateConfig, nil)
setupOptions := []app.Option{app.SkipProductsInitialization()}
th := setupTestHelper(testlib.GetMockStoreForSetupFunctions(), nil, false, false, updateConfig, setupOptions)
statusMock := mocks.StatusStore{}
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
@@ -308,7 +312,8 @@ func SetupConfigWithStoreMock(tb testing.TB, updateConfig func(cfg *model.Config
}
func SetupWithStoreMock(tb testing.TB) *TestHelper {
th := setupTestHelper(testlib.GetMockStoreForSetupFunctions(), nil, false, false, nil, nil)
setupOptions := []app.Option{app.SkipProductsInitialization()}
th := setupTestHelper(testlib.GetMockStoreForSetupFunctions(), nil, false, false, nil, setupOptions)
statusMock := mocks.StatusStore{}
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
@@ -322,7 +327,8 @@ func SetupWithStoreMock(tb testing.TB) *TestHelper {
}
func SetupEnterpriseWithStoreMock(tb testing.TB, options ...app.Option) *TestHelper {
th := setupTestHelper(testlib.GetMockStoreForSetupFunctions(), nil, true, false, nil, options)
setupOptions := append(options, app.SkipProductsInitialization())
th := setupTestHelper(testlib.GetMockStoreForSetupFunctions(), nil, true, false, nil, setupOptions)
statusMock := mocks.StatusStore{}
statusMock.On("UpdateExpiredDNDStatuses").Return([]*model.Status{}, nil)
statusMock.On("Get", "user1").Return(&model.Status{UserId: "user1", Status: model.StatusOnline}, nil)
@@ -479,6 +485,14 @@ func (th *TestHelper) InitBasic() *TestHelper {
return th
}
func (th *TestHelper) DeleteBots() *TestHelper {
preexistingBots, _ := th.App.GetBots(&model.BotGetOptions{Page: 0, PerPage: 100})
for _, bot := range preexistingBots {
th.App.PermanentDeleteBot(bot.UserId)
}
return th
}
func (th *TestHelper) waitForConnectivity() {
for i := 0; i < 1000; i++ {
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%v", th.App.Srv().ListenAddr.Port))

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

@@ -297,11 +297,10 @@ func TestPatchBot(t *testing.T) {
require.NoError(t, err)
CheckOKStatus(t, resp)
bots, resp, err := th.Client.GetBots(0, 2, "")
bot, resp, err := th.Client.GetBot(createdBot.UserId, "")
require.NoError(t, err)
CheckOKStatus(t, resp)
require.Len(t, bots, 1)
require.Equal(t, []*model.Bot{patchedBot}, bots)
require.Equal(t, patchedBot, bot)
})
t.Run("patch my bot without permission", func(t *testing.T) {
@@ -630,7 +629,7 @@ func TestGetBot(t *testing.T) {
}
func TestGetBots(t *testing.T) {
th := Setup(t).InitBasic()
th := Setup(t).InitBasic().DeleteBots()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) {

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

@@ -4140,6 +4140,12 @@ func TestGetChannelModerations(t *testing.T) {
scheme.DefaultChannelGuestRole = ""
mockStore := mocks.Store{}
// Playbooks DB job requires a plugin mock
pluginStore := mocks.PluginStore{}
pluginStore.On("List", mock.Anything, mock.Anything, mock.Anything).Return([]string{}, nil)
mockStore.On("Plugin").Return(&pluginStore)
mockSchemeStore := mocks.SchemeStore{}
mockSchemeStore.On("Get", mock.Anything).Return(scheme, nil)
mockStore.On("Scheme").Return(&mockSchemeStore)
@@ -4282,6 +4288,12 @@ func TestPatchChannelModerations(t *testing.T) {
scheme.DefaultChannelGuestRole = ""
mockStore := mocks.Store{}
// Playbooks DB job requires a plugin mock
pluginStore := mocks.PluginStore{}
pluginStore.On("List", mock.Anything, mock.Anything, mock.Anything).Return([]string{}, nil)
mockStore.On("Plugin").Return(&pluginStore)
mockSchemeStore := mocks.SchemeStore{}
mockSchemeStore.On("Get", mock.Anything).Return(scheme, nil)
mockSchemeStore.On("Save", mock.Anything).Return(scheme, nil)
@@ -4340,7 +4352,6 @@ func TestPatchChannelModerations(t *testing.T) {
require.Equal(t, moderation.Roles.Members.Enabled, true)
}
})
}
func TestGetChannelMemberCountsByGroup(t *testing.T) {

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

@@ -1541,6 +1541,12 @@ func TestGetFlaggedPostsForUser(t *testing.T) {
mockStore.On("License").Return(th.App.Srv().Store().License())
mockStore.On("Role").Return(th.App.Srv().Store().Role())
mockStore.On("Close").Return(nil)
// Playbooks DB job requires a plugin mock
pluginStore := mocks.PluginStore{}
pluginStore.On("List", mock.Anything, mock.Anything, mock.Anything).Return([]string{}, nil)
mockStore.On("Plugin").Return(&pluginStore)
th.App.Srv().SetStore(&mockStore)
_, resp, err = th.SystemAdminClient.GetFlaggedPostsForUser(user.Id, 0, 10)

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

@@ -2714,7 +2714,7 @@ func TestGetUsersInTeam(t *testing.T) {
}
func TestGetUsersNotInTeam(t *testing.T) {
th := Setup(t).InitBasic()
th := Setup(t).InitBasic().DeleteBots()
defer th.TearDown()
teamId := th.BasicTeam.Id