mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
MarshallReader -> marshalReader
This commit is contained in:
parent
18a87c05c6
commit
91b076eec5
2 changed files with 11 additions and 11 deletions
8
viper.go
8
viper.go
|
@ -528,7 +528,7 @@ func (v *viper) ReadInConfig() error {
|
|||
return err
|
||||
}
|
||||
|
||||
v.MarshallReader(bytes.NewReader(file), v.config)
|
||||
v.marshalReader(bytes.NewReader(file), v.config)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -543,8 +543,8 @@ func (v *viper) ReadRemoteConfig() error {
|
|||
|
||||
// Marshall a Reader into a map
|
||||
// Should probably be an unexported function
|
||||
func MarshallReader(in io.Reader, c map[string]interface{}) { v.MarshallReader(in, c) }
|
||||
func (v *viper) MarshallReader(in io.Reader, c map[string]interface{}) {
|
||||
func marshalReader(in io.Reader, c map[string]interface{}) { v.marshalReader(in, c) }
|
||||
func (v *viper) marshalReader(in io.Reader, c map[string]interface{}) {
|
||||
marshallConfigReader(in, c, v.getConfigType())
|
||||
}
|
||||
|
||||
|
@ -598,7 +598,7 @@ func (v *viper) getRemoteConfig(provider *remoteProvider) (map[string]interface{
|
|||
return nil, err
|
||||
}
|
||||
reader := bytes.NewReader(b)
|
||||
v.MarshallReader(reader, v.kvstore)
|
||||
v.marshalReader(reader, v.kvstore)
|
||||
return v.kvstore, err
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ func TestMarshalling(t *testing.T) {
|
|||
SetConfigType("yaml")
|
||||
r := bytes.NewReader(yamlExample)
|
||||
|
||||
MarshallReader(r, v.config)
|
||||
marshalReader(r, v.config)
|
||||
assert.True(t, InConfig("name"))
|
||||
assert.False(t, InConfig("state"))
|
||||
assert.Equal(t, "steve", Get("name"))
|
||||
|
@ -143,7 +143,7 @@ func TestYML(t *testing.T) {
|
|||
SetConfigType("yml")
|
||||
r := bytes.NewReader(yamlExample)
|
||||
|
||||
MarshallReader(r, v.config)
|
||||
marshalReader(r, v.config)
|
||||
assert.Equal(t, "steve", Get("name"))
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ func TestJSON(t *testing.T) {
|
|||
SetConfigType("json")
|
||||
r := bytes.NewReader(jsonExample)
|
||||
|
||||
MarshallReader(r, v.config)
|
||||
marshalReader(r, v.config)
|
||||
assert.Equal(t, "0001", Get("id"))
|
||||
}
|
||||
|
||||
|
@ -159,17 +159,17 @@ func TestTOML(t *testing.T) {
|
|||
SetConfigType("toml")
|
||||
r := bytes.NewReader(tomlExample)
|
||||
|
||||
MarshallReader(r, v.config)
|
||||
marshalReader(r, v.config)
|
||||
assert.Equal(t, "TOML Example", Get("title"))
|
||||
}
|
||||
|
||||
func TestRemotePrecedence(t *testing.T) {
|
||||
SetConfigType("json")
|
||||
r := bytes.NewReader(jsonExample)
|
||||
MarshallReader(r, v.config)
|
||||
marshalReader(r, v.config)
|
||||
remote := bytes.NewReader(remoteExample)
|
||||
assert.Equal(t, "0001", Get("id"))
|
||||
MarshallReader(remote, v.kvstore)
|
||||
marshalReader(remote, v.kvstore)
|
||||
assert.Equal(t, "0001", Get("id"))
|
||||
assert.NotEqual(t, "cronut", Get("type"))
|
||||
assert.Equal(t, "remote", Get("newkey"))
|
||||
|
@ -182,7 +182,7 @@ func TestRemotePrecedence(t *testing.T) {
|
|||
func TestEnv(t *testing.T) {
|
||||
SetConfigType("json")
|
||||
r := bytes.NewReader(jsonExample)
|
||||
MarshallReader(r, v.config)
|
||||
marshalReader(r, v.config)
|
||||
BindEnv("id")
|
||||
BindEnv("f", "FOOD")
|
||||
|
||||
|
|
Loading…
Reference in a new issue