MM-23250: improve config.Migrate tests (#14479)
* MM-23250: improve config.Migrate tests The config.Migrate tests were not running in isolation, but wrote over the "local" config. The test coverage for both directions was not exhaustive, and lacked coverage for the recently added plugin signature files. Rewrite the unit tests as such, fixing a minor issue closing the stores after migration. Fixes: https://mattermost.atlassian.net/browse/MM-23250 * idiomatic err checking * clarify random file contents Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0154b8059b
Коммит
ee8bd4ece4
@@ -11,29 +11,33 @@ func Migrate(from, to string) error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to access source config %s", from)
|
||||
}
|
||||
defer source.Close()
|
||||
|
||||
destination, err := NewStore(to, false)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to access destination config %s", to)
|
||||
}
|
||||
defer destination.Close()
|
||||
|
||||
sourceConfig := source.Get()
|
||||
if _, err = destination.Set(sourceConfig); err != nil {
|
||||
return errors.Wrapf(err, "failed to set config")
|
||||
}
|
||||
|
||||
files := []string{*sourceConfig.SamlSettings.IdpCertificateFile, *sourceConfig.SamlSettings.PublicCertificateFile,
|
||||
*sourceConfig.SamlSettings.PrivateKeyFile}
|
||||
files := []string{
|
||||
*sourceConfig.SamlSettings.IdpCertificateFile,
|
||||
*sourceConfig.SamlSettings.PublicCertificateFile,
|
||||
*sourceConfig.SamlSettings.PrivateKeyFile,
|
||||
}
|
||||
|
||||
files = append(files, sourceConfig.PluginSettings.SignaturePublicKeyFiles...)
|
||||
|
||||
for _, file := range files {
|
||||
err = migrateFile(file, source, destination)
|
||||
|
||||
if err != nil {
|
||||
if err := migrateFile(file, source, destination); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user