mirror of https://github.com/spf13/viper.git
[DOC] add MapTo test
This commit is contained in:
parent
a62e20b9ad
commit
3390ac2d91
|
@ -513,12 +513,17 @@ func TestMapTo(t *testing.T) {
|
||||||
"ip": "127.0.0.1",
|
"ip": "127.0.0.1",
|
||||||
"port": 1234,
|
"port": 1234,
|
||||||
})
|
})
|
||||||
|
SetDefault("version", "1.0.01")
|
||||||
|
|
||||||
var service Service
|
var service Service
|
||||||
|
var version string
|
||||||
err := MapTo("service", &service)
|
err := MapTo("service", &service)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, Get("service.port"), service.Port)
|
assert.Equal(t, Get("service.port"), service.Port)
|
||||||
assert.Equal(t, Get("service.ip"), service.IP)
|
assert.Equal(t, Get("service.ip"), service.IP)
|
||||||
|
err = MapTo("version", &version)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, Get("version"), version)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue