fix: conf anonymous overlay problem (#2847)

This commit is contained in:
Kevin Wan
2023-02-05 14:40:57 +08:00
committed by GitHub
parent aed312f3c0
commit a019a1f59f
4 changed files with 55 additions and 15 deletions

View File

@@ -420,6 +420,42 @@ func TestLoadFromYamlItemOverlay(t *testing.T) {
}
}
func TestLoadFromYamlItemOverlayReverse(t *testing.T) {
type (
Redis struct {
Host string
Port int
}
RedisKey struct {
Redis
Key string
}
Server struct {
Redis Redis
}
TestConfig struct {
Redis RedisKey
Server
}
)
input := []byte(`Redis:
Host: localhost
Port: 6379
Key: test
`)
var c TestConfig
if assert.NoError(t, LoadFromYamlBytes(input, &c)) {
assert.Equal(t, "localhost", c.Redis.Host)
assert.Equal(t, 6379, c.Redis.Port)
assert.Equal(t, "test", c.Redis.Key)
}
}
func TestLoadFromYamlItemOverlayWithMap(t *testing.T) {
type (
Redis struct {