test: refactor read config test

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
Mark Sagi-Kazar 2024-06-05 10:28:54 +02:00 committed by Márk Sági-Kazár
parent 3266e43d90
commit e8707fde20

View file

@ -1641,10 +1641,12 @@ func TestFindsNestedKeys(t *testing.T) {
} }
} }
func TestReadBufConfig(t *testing.T) { func TestReadConfig(t *testing.T) {
t.Run("ok", func(t *testing.T) {
v := New() v := New()
v.SetConfigType("yaml") v.SetConfigType("yaml")
v.ReadConfig(bytes.NewBuffer(yamlExample)) err := v.ReadConfig(bytes.NewBuffer(yamlExample))
require.NoError(t, err)
t.Log(v.AllKeys()) t.Log(v.AllKeys())
assert.True(t, v.InConfig("name")) assert.True(t, v.InConfig("name"))
@ -1655,6 +1657,7 @@ func TestReadBufConfig(t *testing.T) {
assert.Equal(t, []any{"skateboarding", "snowboarding", "go"}, v.Get("hobbies")) assert.Equal(t, []any{"skateboarding", "snowboarding", "go"}, v.Get("hobbies"))
assert.Equal(t, map[string]any{"jacket": "leather", "trousers": "denim", "pants": map[string]any{"size": "large"}}, v.Get("clothing")) assert.Equal(t, map[string]any{"jacket": "leather", "trousers": "denim", "pants": map[string]any{"size": "large"}}, v.Get("clothing"))
assert.Equal(t, 35, v.Get("age")) assert.Equal(t, 35, v.Get("age"))
})
} }
func TestIsSet(t *testing.T) { func TestIsSet(t *testing.T) {