Upgrading server dependancies (#6215)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
7f68a60f8c
Коммит
f5437632f4
67
vendor/github.com/spf13/viper/viper_test.go
сгенерированный
поставляемый
67
vendor/github.com/spf13/viper/viper_test.go
сгенерированный
поставляемый
@@ -538,6 +538,44 @@ func TestBindPFlags(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestBindPFlagsStringSlice(t *testing.T) {
|
||||
for _, testValue := range []struct {
|
||||
Expected []string
|
||||
Value string
|
||||
}{
|
||||
{[]string{}, ""},
|
||||
{[]string{"jeden"}, "jeden"},
|
||||
{[]string{"dwa", "trzy"}, "dwa,trzy"},
|
||||
{[]string{"cztery", "piec , szesc"}, "cztery,\"piec , szesc\""}} {
|
||||
|
||||
for _, changed := range []bool{true, false} {
|
||||
v := New() // create independent Viper object
|
||||
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
|
||||
}
|
||||
})
|
||||
|
||||
err := v.BindPFlags(flagSet)
|
||||
if err != nil {
|
||||
t.Fatalf("error binding flag set, %v", err)
|
||||
}
|
||||
|
||||
type TestStr struct {
|
||||
StringSlice []string
|
||||
}
|
||||
val := &TestStr{}
|
||||
if err := v.Unmarshal(val); err != nil {
|
||||
t.Fatalf("%+#v cannot unmarshal: %s", testValue.Value, err)
|
||||
}
|
||||
assert.Equal(t, testValue.Expected, val.StringSlice)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBindPFlag(t *testing.T) {
|
||||
var testString = "testing"
|
||||
var testValue = newStringValue(testString, &testString)
|
||||
@@ -1102,6 +1140,35 @@ func TestCaseInsensitiveSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseNested(t *testing.T) {
|
||||
type duration struct {
|
||||
Delay time.Duration
|
||||
}
|
||||
|
||||
type item struct {
|
||||
Name string
|
||||
Delay time.Duration
|
||||
Nested duration
|
||||
}
|
||||
|
||||
config := `[[parent]]
|
||||
delay="100ms"
|
||||
[parent.nested]
|
||||
delay="200ms"
|
||||
`
|
||||
initConfig("toml", config)
|
||||
|
||||
var items []item
|
||||
err := v.UnmarshalKey("parent", &items)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to decode into struct, %v", err)
|
||||
}
|
||||
|
||||
assert.Equal(t, 1, len(items))
|
||||
assert.Equal(t, 100*time.Millisecond, items[0].Delay)
|
||||
assert.Equal(t, 200*time.Millisecond, items[0].Nested.Delay)
|
||||
}
|
||||
|
||||
func doTestCaseInsensitive(t *testing.T, typ, config string) {
|
||||
initConfig(typ, config)
|
||||
Set("RfD", true)
|
||||
|
||||
Ссылка в новой задаче
Block a user