Skip to content

Commit

Permalink
Add breaking test that requires reverting #673
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Sep 28, 2019
1 parent 371f39c commit 398adc5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions viper_test.go
Expand Up @@ -254,7 +254,7 @@ func initDirs(t *testing.T) (string, string, func()) {
}
}

//stubs for PFlag Values
// stubs for PFlag Values
type stringValue string

func newStringValue(val string, p *string) *stringValue {
Expand Down Expand Up @@ -864,7 +864,7 @@ func TestBindPFlag(t *testing.T) {
assert.Equal(t, testString, Get("testvalue"))

flag.Value.Set("testing_mutate")
flag.Changed = true //hack for pflag usage
flag.Changed = true // hack for pflag usage

assert.Equal(t, "testing_mutate", Get("testvalue"))

Expand Down Expand Up @@ -1856,6 +1856,23 @@ func TestWatchFile(t *testing.T) {

}

func TestUnmarshal_DotSeparatorBackwardCompatibility(t *testing.T) {
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
flags.String("foo.bar", "cobra_flag", "")

v := New()
assert.NoError(t, v.BindPFlags(flags))

config := &struct {
Foo struct {
Bar string
}
}{}

assert.NoError(t, v.Unmarshal(config))
assert.Equal(t, "cobra_flag", config.Foo.Bar)
}

func BenchmarkGetBool(b *testing.B) {
key := "BenchmarkGetBool"
v = New()
Expand Down

0 comments on commit 398adc5

Please sign in to comment.