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
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestUpAndDownMigrations(t *testing.T) {
|
||||
@@ -23,7 +24,8 @@ func TestUpAndDownMigrations(t *testing.T) {
|
||||
t.Skip(err)
|
||||
}
|
||||
|
||||
store := New(*settings, nil)
|
||||
store, err := New(*settings, nil)
|
||||
require.NoError(t, err)
|
||||
defer store.Close()
|
||||
|
||||
err = store.migrate(migrationsDirectionDown, false)
|
||||
|
||||
Ссылка в новой задаче
Block a user