fix: key like TLSConfig not working (#2730)

* fix: key like TLSConfig not working

* fix: remove unnecessary code

* chore: rename variable
This commit is contained in:
Kevin Wan
2022-12-29 14:50:53 +08:00
committed by GitHub
parent ce1c02f4f9
commit c7a0ec428c
2 changed files with 43 additions and 69 deletions

View File

@@ -237,23 +237,23 @@ func TestToCamelCase(t *testing.T) {
},
{
input: "hello_world",
expect: "helloWorld",
expect: "hello_world",
},
{
input: "Hello_world",
expect: "helloWorld",
expect: "hello_world",
},
{
input: "hello_World",
expect: "helloWorld",
expect: "hello_world",
},
{
input: "helloWorld",
expect: "helloWorld",
expect: "helloworld",
},
{
input: "HelloWorld",
expect: "helloWorld",
expect: "helloworld",
},
{
input: "hello World",
@@ -269,34 +269,34 @@ func TestToCamelCase(t *testing.T) {
},
{
input: "Hello World foo_bar",
expect: "hello world fooBar",
expect: "hello world foo_bar",
},
{
input: "Hello World foo_Bar",
expect: "hello world fooBar",
expect: "hello world foo_bar",
},
{
input: "Hello World Foo_bar",
expect: "hello world fooBar",
expect: "hello world foo_bar",
},
{
input: "Hello World Foo_Bar",
expect: "hello world fooBar",
expect: "hello world foo_bar",
},
{
input: "Hello.World Foo_Bar",
expect: "hello.world fooBar",
expect: "hello.world foo_bar",
},
{
input: "你好 World Foo_Bar",
expect: "你好 world fooBar",
expect: "你好 world foo_bar",
},
}
for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
assert.Equal(t, test.expect, toCamelCase(test.input))
assert.Equal(t, test.expect, toLowerCase(test.input))
})
}
}
@@ -332,6 +332,22 @@ func TestLoadFromYamlBytes(t *testing.T) {
assert.Equal(t, "foo", val.Layer1.Layer2.Layer3)
}
func TestLoadFromYamlBytesTerm(t *testing.T) {
input := []byte(`layer1:
layer2:
tls_conf: foo`)
var val struct {
Layer1 struct {
Layer2 struct {
Layer3 string `json:"tls_conf"`
}
}
}
assert.NoError(t, LoadFromYamlBytes(input, &val))
assert.Equal(t, "foo", val.Layer1.Layer2.Layer3)
}
func TestLoadFromYamlBytesLayers(t *testing.T) {
input := []byte(`layer1:
layer2: