From a1f26b11bd9b3c24a399da565ce95191fbc10759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9ra=20Zolt=C3=A1n?= Date: Fri, 15 Jan 2021 15:18:17 +0200 Subject: [PATCH] Add test for cannot write hidden file without extension --- viper_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/viper_test.go b/viper_test.go index 080d0c4..c371c07 100644 --- a/viper_test.go +++ b/viper_test.go @@ -1742,6 +1742,23 @@ func TestSafeWriteConfigAsWithExistingFile(t *testing.T) { assert.True(t, ok, "Expected ConfigFileAlreadyExistsError") } +func TestWriteHiddenFile(t *testing.T) { + v := New() + fs := afero.NewMemMapFs() + fs.Create("/test/.config") + v.SetFs(fs) + + v.SetConfigName(".config") + v.SetConfigType("yaml") + v.AddConfigPath("/test") + + err := v.ReadInConfig() + require.NoError(t, err) + + err = v.WriteConfig() + require.NoError(t, err) +} + var yamlMergeExampleTgt = []byte(` hello: pop: 37890