From 3390ac2d915f95eb2c8b0f5a53f16f413068c5a8 Mon Sep 17 00:00:00 2001 From: Nothin Date: Sat, 15 Apr 2023 15:00:27 +0800 Subject: [PATCH] [DOC] add MapTo test --- viper_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/viper_test.go b/viper_test.go index 5596724..1e7e266 100644 --- a/viper_test.go +++ b/viper_test.go @@ -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) }