mirror of https://github.com/spf13/viper.git
Add test for writing invalid ini
This commit is contained in:
parent
97ee7adfef
commit
896fc959b3
|
@ -1558,6 +1558,22 @@ func TestWriteConfigDotEnv(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWriteConfigInvalidIni(t *testing.T) {
|
||||||
|
v := New()
|
||||||
|
fs := afero.NewMemMapFs()
|
||||||
|
v.SetFs(fs)
|
||||||
|
v.SetConfigName("c")
|
||||||
|
v.SetConfigType("ini")
|
||||||
|
v.Set("x", "y")
|
||||||
|
err := v.WriteConfigAs("c.ini")
|
||||||
|
require.NotNil(t, err, "invalid ini is expected to return an error")
|
||||||
|
_, ok := err.(ConfigMarshalError)
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("ConfigMarshalError type is expected, but got %T type",
|
||||||
|
err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSafeWriteConfig(t *testing.T) {
|
func TestSafeWriteConfig(t *testing.T) {
|
||||||
v := New()
|
v := New()
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
|
|
Loading…
Reference in New Issue