Add test for writing invalid ini

This commit is contained in:
gopherclass 2020-03-09 19:30:20 +09:00
parent 97ee7adfef
commit 896fc959b3

View file

@ -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) {
v := New()
fs := afero.NewMemMapFs()