Add breaking test that requires reverting #673 - viper - [fork] go viper port for 9front
(HTM) git clone git@git.drkhsh.at/viper.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 398adc5a7da8f7fb1dda192beb2a9db63f797445
(DIR) parent 371f39c3ab6ffb983f89c737291fe9ec8a5096c7
(HTM) Author: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Date: Fri, 27 Sep 2019 17:09:18 +0200
Add breaking test that requires reverting #673
Diffstat:
M viper_test.go | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/viper_test.go b/viper_test.go
@@ -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 {
@@ -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"))
@@ -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()