mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
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:
parent
e8707fde20
commit
afe3be23cb
1 changed files with 7 additions and 0 deletions
|
@ -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"))
|
||||||
|
|
Loading…
Reference in a new issue