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

Function TestMultipleEnv

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

Source from the content-addressed store, hash-verified

627}
628
629func TestMultipleEnv(t *testing.T) {
630 v := New()
631 v.SetConfigType("json")
632 // Read the JSON data into Viper configuration v.config
633 require.NoError(t, v.ReadConfig(bytes.NewBuffer(jsonExample)), "Error reading json data")
634
635 v.BindEnv("f", "FOOD", "OLD_FOOD")
636
637 t.Setenv("OLD_FOOD", "banana")
638
639 assert.Equal(t, "banana", v.Get("f"))
640}
641
642func TestEmptyEnv(t *testing.T) {
643 v := New()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
SetConfigTypeMethod · 0.80
ReadConfigMethod · 0.80
BindEnvMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected