Add tests for EncodeConfig

This commit is contained in:
Evgeniy Kulikov 2020-02-10 15:27:24 +03:00
parent 49926d59ac
commit 02e82156ba
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2

View file

@ -5,6 +5,7 @@ import (
"expvar"
"testing"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
)
@ -26,3 +27,23 @@ func TestEncodeVariables(t *testing.T) {
require.Contains(t, dump, "test2")
require.Equal(t, "test2", dump["test2"])
}
func TestEncodeConfig(t *testing.T) {
v := viper.New()
v.Set("test1", "test1")
v.Set("test2", "test2")
res, err := EncodeConfig(v)
require.NoError(t, err)
dump := make(map[string]interface{})
require.NoError(t, json.Unmarshal(res.Config, &dump))
require.NotEmpty(t, dump)
require.Contains(t, dump, "test1")
require.Equal(t, dump["test1"], "test1")
require.Contains(t, dump, "test2")
require.Equal(t, dump["test2"], "test2")
}