github.com/wgh-/mattermost-server@v4.8.0-rc2+incompatible/api4/api_test.go (about) 1 // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package api4 5 6 import ( 7 "flag" 8 "os" 9 "testing" 10 11 l4g "github.com/alecthomas/log4go" 12 13 "github.com/mattermost/mattermost-server/store/storetest" 14 "github.com/mattermost/mattermost-server/utils" 15 ) 16 17 func TestMain(m *testing.M) { 18 flag.Parse() 19 utils.TranslationsPreInit() 20 21 // In the case where a dev just wants to run a single test, it's faster to just use the default 22 // store. 23 if filter := flag.Lookup("test.run").Value.String(); filter != "" && filter != "." { 24 l4g.Info("-test.run used, not creating temporary containers") 25 os.Exit(m.Run()) 26 } 27 28 status := 0 29 30 container, settings, err := storetest.NewMySQLContainer() 31 if err != nil { 32 panic(err) 33 } 34 35 UseTestStore(container, settings) 36 37 defer func() { 38 StopTestStore() 39 os.Exit(status) 40 }() 41 42 status = m.Run() 43 }