Skip to content

Commit

Permalink
Fixed TestBindPFlagsStringSlice()
Browse files Browse the repository at this point in the history
Replaced Visit() by VisitAll(), so that the Changed attribute of
the updated flag is correctly set.
  • Loading branch information
benoitmasson authored and bep committed Nov 7, 2018
1 parent cc7e906 commit 69647fb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions viper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,9 @@ func TestBindPFlagsStringSlice(t *testing.T) {

flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
flagSet.StringSlice("stringslice", testValue.Expected, "test")
flagSet.Visit(func(f *pflag.Flag) {
if len(testValue.Value) > 0 {
f.Value.Set(testValue.Value)
f.Changed = changed
}
flagSet.VisitAll(func(f *pflag.Flag) {
f.Value.Set(testValue.Value)
f.Changed = changed
})

err := v.BindPFlags(flagSet)
Expand Down

0 comments on commit 69647fb

Please sign in to comment.