Fail vs. fatal on store startup (#24170)

If the store fails to initialize (e.g. run a migration), it would `log.Fatal` and then `os.Exit`. Unfortunately, this trips up `TestMain`, which happily keeps running tests, now guaranteed to fail.

Avoid this by instead returning an error from the store initialization, handling appropriately at the layer above.
Этот коммит содержится в:
Jesse Hallam
2023-08-04 23:05:01 -03:00
коммит произвёл GitHub
родитель c030bb44f5
Коммит e39b485c4b
11 изменённых файлов: 98 добавлений и 41 удалений

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

@@ -49,7 +49,12 @@ func (s *BleveEngineTestSuite) setupStore() {
driverName = model.DatabaseDriverPostgres
}
s.SQLSettings = storetest.MakeSqlSettings(driverName, false)
s.SQLStore = sqlstore.New(*s.SQLSettings, nil)
var err error
s.SQLStore, err = sqlstore.New(*s.SQLSettings, nil)
if err != nil {
s.Require().FailNow("Cannot initialize store: %s", err.Error())
}
cfg := &model.Config{}
cfg.SetDefaults()