mirror of
https://github.com/spf13/viper
synced 2024-12-23 12:07:02 +00:00
Add test for writing invalid ini
This commit is contained in:
parent
97ee7adfef
commit
896fc959b3
1 changed files with 16 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue