Preserve envPrefix in Sub

This commit is contained in:
TaylorOno
2023-02-25 22:17:36 +01:00
committed by Márk Sági-Kazár
parent 3f4449054d
commit 3970ad177e
2 changed files with 8 additions and 2 deletions
+7 -2
View File
@@ -738,12 +738,17 @@ func TestEnvSubConfig(t *testing.T) {
v.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
v.SetEnvKeyReplacer(replacer)
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
testutil.Setenv(t, "CLOTHING_PANTS_SIZE", "small")
subv := v.Sub("clothing").Sub("pants")
assert.Equal(t, "small", subv.Get("size"))
// again with EnvPrefix
v.SetEnvPrefix("foo") // will be uppercased automatically
subWithPrefix := v.Sub("clothing").Sub("pants")
testutil.Setenv(t, "FOO_CLOTHING_PANTS_SIZE", "large")
assert.Equal(t, "large", subWithPrefix.Get("size"))
}
func TestAllKeys(t *testing.T) {