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.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c030bb44f5
Коммит
e39b485c4b
@@ -118,7 +118,12 @@ func (h *MainHelper) setupStore(withReadReplica bool) {
|
||||
|
||||
h.SearchEngine = searchengine.NewBroker(config)
|
||||
h.ClusterInterface = &FakeClusterInterface{}
|
||||
h.SQLStore = sqlstore.New(*h.Settings, nil)
|
||||
|
||||
var err error
|
||||
h.SQLStore, err = sqlstore.New(*h.Settings, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
h.Store = searchlayer.NewSearchLayer(&TestStore{
|
||||
h.SQLStore,
|
||||
}, h.SearchEngine, config)
|
||||
@@ -130,7 +135,12 @@ func (h *MainHelper) ToggleReplicasOff() {
|
||||
}
|
||||
h.Settings.DataSourceReplicas = []string{}
|
||||
lic := h.SQLStore.GetLicense()
|
||||
h.SQLStore = sqlstore.New(*h.Settings, nil)
|
||||
|
||||
var err error
|
||||
h.SQLStore, err = sqlstore.New(*h.Settings, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
h.SQLStore.UpdateLicense(lic)
|
||||
}
|
||||
|
||||
@@ -140,7 +150,13 @@ func (h *MainHelper) ToggleReplicasOn() {
|
||||
}
|
||||
h.Settings.DataSourceReplicas = h.replicas
|
||||
lic := h.SQLStore.GetLicense()
|
||||
h.SQLStore = sqlstore.New(*h.Settings, nil)
|
||||
|
||||
var err error
|
||||
h.SQLStore, err = sqlstore.New(*h.Settings, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
h.SQLStore.UpdateLicense(lic)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user