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

Function TestDefault

viper_test.go:469–482  ·  viper_test.go::TestDefault
(t *testing.T)

Source from the content-addressed store, hash-verified

467}
468
469func TestDefault(t *testing.T) {
470 v := New()
471 v.SetDefault("age", 45)
472 assert.Equal(t, 45, v.Get("age"))
473
474 v.SetDefault("clothing.jacket", "slacks")
475 assert.Equal(t, "slacks", v.Get("clothing.jacket"))
476
477 v.SetConfigType("yaml")
478 err := v.ReadConfig(bytes.NewBuffer(yamlExample))
479
480 require.NoError(t, err)
481 assert.Equal(t, "leather", v.Get("clothing.jacket"))
482}
483
484func TestUnmarshaling(t *testing.T) {
485 v := New()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected