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

Function TestUnmarshal_DotSeparatorBackwardCompatibility

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

Source from the content-addressed store, hash-verified

2462}
2463
2464func TestUnmarshal_DotSeparatorBackwardCompatibility(t *testing.T) {
2465 flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
2466 flags.String("foo.bar", "cobra_flag", "")
2467
2468 v := New()
2469 assert.NoError(t, v.BindPFlags(flags))
2470
2471 config := &struct {
2472 Foo struct {
2473 Bar string
2474 }
2475 }{}
2476
2477 assert.NoError(t, v.Unmarshal(config))
2478 assert.Equal(t, "cobra_flag", config.Foo.Bar)
2479}
2480
2481// var yamlExampleWithDot = []byte(`Hacker: true
2482// name: steve

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
StringMethod · 0.80
BindPFlagsMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected