mirror of
https://github.com/spf13/viper
synced 2024-12-23 03:57:01 +00:00
[DOC] add MapTo test
This commit is contained in:
parent
a62e20b9ad
commit
3390ac2d91
1 changed files with 5 additions and 0 deletions
|
@ -513,12 +513,17 @@ func TestMapTo(t *testing.T) {
|
|||
"ip": "127.0.0.1",
|
||||
"port": 1234,
|
||||
})
|
||||
SetDefault("version", "1.0.01")
|
||||
|
||||
var service Service
|
||||
var version string
|
||||
err := MapTo("service", &service)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, Get("service.port"), service.Port)
|
||||
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 a new issue