test: add failing test for reading config without a config type

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

View file

@ -1658,6 +1658,12 @@ func TestReadConfig(t *testing.T) {
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"))
}) })
t.Run("missing config type", func(t *testing.T) {
v := New()
err := v.ReadConfig(bytes.NewBuffer(yamlExample))
require.Error(t, err)
})
} }
func TestIsSet(t *testing.T) { func TestIsSet(t *testing.T) {
@ -2130,6 +2136,7 @@ func TestSafeWriteAsConfig(t *testing.T) {
v := New() v := New()
fs := afero.NewMemMapFs() fs := afero.NewMemMapFs()
v.SetFs(fs) v.SetFs(fs)
v.SetConfigType("yaml")
err := v.ReadConfig(bytes.NewBuffer(yamlExample)) err := v.ReadConfig(bytes.NewBuffer(yamlExample))
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, v.SafeWriteConfigAs("/test/c.yaml")) require.NoError(t, v.SafeWriteConfigAs("/test/c.yaml"))