MCPcopy
hub / github.com/spf13/viper / TestAllKeysWithEnv

Function TestAllKeysWithEnv

viper_test.go:824–836  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

822}
823
824func TestAllKeysWithEnv(t *testing.T) {
825 v := New()
826
827 // bind and define environment variables (including a nested one)
828 v.BindEnv("id")
829 v.BindEnv("foo.bar")
830 v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
831
832 t.Setenv("ID", "13")
833 t.Setenv("FOO_BAR", "baz")
834
835 assert.ElementsMatch(t, []string{"id", "foo.bar"}, v.AllKeys())
836}
837
838func TestAliasesOfAliases(t *testing.T) {
839 v := New()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
BindEnvMethod · 0.80
SetEnvKeyReplacerMethod · 0.80
AllKeysMethod · 0.80

Tested by

no test coverage detected