[DOC] add MapTo test

This commit is contained in:
Nothin 2023-04-15 15:00:27 +08:00
parent a62e20b9ad
commit 3390ac2d91

View file

@ -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)
} }