(t *testing.T)
| 732 | } |
| 733 | |
| 734 | func TestEnvSubConfig(t *testing.T) { |
| 735 | v := New() |
| 736 | v.SetConfigType("yaml") |
| 737 | // Read the YAML data into Viper configuration v.config |
| 738 | require.NoError(t, v.ReadConfig(bytes.NewBuffer(yamlExample)), "Error reading json data") |
| 739 | v.AutomaticEnv() |
| 740 | v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) |
| 741 | |
| 742 | t.Setenv("CLOTHING_PANTS_SIZE", "small") |
| 743 | subv := v.Sub("clothing").Sub("pants") |
| 744 | assert.Equal(t, "small", subv.Get("size")) |
| 745 | |
| 746 | // again with EnvPrefix |
| 747 | v.SetEnvPrefix("foo") // will be uppercased automatically |
| 748 | subWithPrefix := v.Sub("clothing").Sub("pants") |
| 749 | t.Setenv("FOO_CLOTHING_PANTS_SIZE", "large") |
| 750 | assert.Equal(t, "large", subWithPrefix.Get("size")) |
| 751 | } |
| 752 | |
| 753 | func TestAllKeys(t *testing.T) { |
| 754 | v := New() |
nothing calls this directly
no test coverage detected