mirror of
https://github.com/mattermost/mattermost.git
synced 2026-10-29 17:33:26 +08:00
sqlstore's TestMain calls sqlstore.InitTest (which opens postgres and drops tables) before mainHelper.Main, so the -test.list bailout added in #36222 never fired and shard-split discovery failed on the GitHub host. Bail out at the top of TestMain instead, and restore HEAVY_MS so sqlstore can still be treated as whole. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Mattermost Build <build@mattermost.com>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package sqlstore_test
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
"github.com/mattermost/mattermost/server/v8/channels/store/sqlstore"
|
|
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
|
)
|
|
|
|
var mainHelper *testlib.MainHelper
|
|
|
|
func TestMain(m *testing.M) {
|
|
flag.Parse()
|
|
|
|
if f := flag.Lookup("test.list"); f != nil && f.Value.String() != "" {
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
var parallelism int
|
|
if f := flag.Lookup("test.parallel"); f != nil {
|
|
parallelism, _ = strconv.Atoi(f.Value.String())
|
|
}
|
|
runParallel := os.Getenv("ENABLE_FULLY_PARALLEL_TESTS") == "true" && parallelism > 1
|
|
if runParallel {
|
|
mlog.Info("Fully parallel tests enabled", mlog.Int("parallelism", parallelism))
|
|
} else {
|
|
parallelism = 1
|
|
}
|
|
|
|
mainHelper = testlib.NewMainHelperWithOptions(nil)
|
|
defer mainHelper.Close()
|
|
|
|
sqlstore.InitTest(mainHelper.Logger, parallelism)
|
|
|
|
mainHelper.Main(m)
|
|
sqlstore.TearDownTest()
|
|
}
|