mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
5edd96ae77
* seperate services for env + req * merge with main * fix tests * undo changes to golden file * fix linter * remove unused fields * split out new config struct * provide config * undo go mod changes * more renaming * fix tests * undo bra.toml changes * update go.work.sum * undo changes * trigger * apply PR feedback
39 lines
875 B
Go
39 lines
875 B
Go
package pluginconfig
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gopkg.in/ini.v1"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPluginSettings(t *testing.T) {
|
|
raw, err := ini.Load([]byte(`
|
|
[plugins]
|
|
test_key = 123
|
|
|
|
[plugin.test-datasource]
|
|
foo = 5m
|
|
bar = something
|
|
|
|
[plugin.secret-plugin]
|
|
secret_key = secret
|
|
normal_key = not a secret`))
|
|
require.NoError(t, err)
|
|
|
|
cfg := &setting.Cfg{Raw: raw}
|
|
settings := &setting.OSSImpl{Cfg: cfg}
|
|
|
|
ps := extractPluginSettings(settings)
|
|
require.Len(t, ps, 2)
|
|
require.Len(t, ps["test-datasource"], 2)
|
|
require.Equal(t, ps["test-datasource"]["foo"], "5m")
|
|
require.Equal(t, ps["test-datasource"]["bar"], "something")
|
|
require.Len(t, ps["secret-plugin"], 2)
|
|
require.Equal(t, ps["secret-plugin"]["secret_key"], "secret")
|
|
require.Equal(t, ps["secret-plugin"]["normal_key"], "not a secret")
|
|
}
|