mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* TestGetLicenseFileFromDisk: avoid using fileutils.FindConfigFile * config: abstract config-related file access, extend memory store * simplify config validate to avoid file knowledge * fix relative file tests * cluster: fix ConfigChanged event The old and new configurations were swapped when notifying the enterprise code of configuration changes, creating needless instability in propagating config updates across a cluster. * config/database: ignore duplicates * test cleanup * remove unnecessary Save() in test
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package config_test
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost-server/config"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewStore(t *testing.T) {
|
|
sqlSettings := mainHelper.GetSqlSettings()
|
|
|
|
tempDir, err := ioutil.TempDir("", "TestNewStore")
|
|
require.NoError(t, err)
|
|
|
|
err = os.Chdir(tempDir)
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, os.Mkdir(filepath.Join(tempDir, "config"), 0700))
|
|
|
|
t.Run("database dsn", func(t *testing.T) {
|
|
ds, err := config.NewStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource), false)
|
|
require.NoError(t, err)
|
|
ds.Close()
|
|
})
|
|
|
|
t.Run("database dsn, watch ignored", func(t *testing.T) {
|
|
ds, err := config.NewStore(fmt.Sprintf("%s://%s", *sqlSettings.DriverName, *sqlSettings.DataSource), true)
|
|
require.NoError(t, err)
|
|
ds.Close()
|
|
})
|
|
|
|
t.Run("file dsn", func(t *testing.T) {
|
|
fs, err := config.NewStore("config.json", false)
|
|
require.NoError(t, err)
|
|
fs.Close()
|
|
})
|
|
|
|
t.Run("file dsn, watch", func(t *testing.T) {
|
|
fs, err := config.NewStore("config.json", true)
|
|
require.NoError(t, err)
|
|
fs.Close()
|
|
})
|
|
}
|