[MM-40712] config: Bugfix on path resolution; fail if given config does not exist (#19360)
* config: bugfix on path resolution; fail if given config does not exist * reflect review comments Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c554bbd977
Коммит
e03384c4d1
@@ -4,6 +4,7 @@
|
||||
package api4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@@ -776,11 +777,22 @@ func TestMigrateConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
f, err := config.NewStoreFromDSN("from.json", false, nil)
|
||||
cfg := &model.Config{}
|
||||
cfg.SetDefaults()
|
||||
|
||||
file, err := json.MarshalIndent(cfg, "", " ")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = ioutil.WriteFile("from.json", file, 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
defer os.Remove("from.json")
|
||||
|
||||
f, err := config.NewStoreFromDSN("from.json", false, nil, false)
|
||||
require.NoError(t, err)
|
||||
defer f.RemoveFile("from.json")
|
||||
|
||||
_, err = config.NewStoreFromDSN("to.json", false, nil)
|
||||
_, err = config.NewStoreFromDSN("to.json", false, nil, true)
|
||||
require.NoError(t, err)
|
||||
defer f.RemoveFile("to.json")
|
||||
|
||||
@@ -791,11 +803,11 @@ func TestMigrateConfig(t *testing.T) {
|
||||
t.Run("Cloud instances should not access to this API", func(t *testing.T) {
|
||||
require.True(t, th.App.Srv().SetLicense(model.NewTestLicense("cloud")))
|
||||
|
||||
f, err := config.NewStoreFromDSN("from.json", false, nil)
|
||||
f, err := config.NewStoreFromDSN("from.json", false, nil, true)
|
||||
require.NoError(t, err)
|
||||
defer f.RemoveFile("from.json")
|
||||
|
||||
_, err = config.NewStoreFromDSN("to.json", false, nil)
|
||||
_, err = config.NewStoreFromDSN("to.json", false, nil, false)
|
||||
require.NoError(t, err)
|
||||
defer f.RemoveFile("to.json")
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user