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

Function TestEmptyEnv

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

Source from the content-addressed store, hash-verified

640}
641
642func TestEmptyEnv(t *testing.T) {
643 v := New()
644 v.SetConfigType("json")
645 // Read the JSON data into Viper configuration v.config
646 require.NoError(t, v.ReadConfig(bytes.NewBuffer(jsonExample)), "Error reading json data")
647
648 v.BindEnv("type") // Empty environment variable
649 v.BindEnv("name") // Bound, but not set environment variable
650
651 t.Setenv("TYPE", "")
652
653 assert.Equal(t, "donut", v.Get("type"))
654 assert.Equal(t, "Cake", v.Get("name"))
655}
656
657func TestEmptyEnv_Allowed(t *testing.T) {
658 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