From aa2bb3a53792fc6437ba324072cfa1660f9e4f04 Mon Sep 17 00:00:00 2001 From: koooge Date: Thu, 24 May 2018 18:05:24 +0000 Subject: [PATCH] Create getDefaultConfigFile() test --- viper_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/viper_test.go b/viper_test.go index 60543f5..4d8f3ff 100644 --- a/viper_test.go +++ b/viper_test.go @@ -12,6 +12,7 @@ import ( "io/ioutil" "os" "path" + "path/filepath" "reflect" "sort" "strings" @@ -1032,6 +1033,22 @@ func TestWriteConfigYAML(t *testing.T) { assert.Equal(t, yamlWriteExpected, read) } +func TestGetDefaultConfigFile(t *testing.T) { + v := New() + home, err := filepath.Abs("/homedir") + if err != nil { + t.Fatal(err) + } + v.AddConfigPath(home) + v.SetConfigName("c") + filename, err := v.getDefaultConfigFile() + if err != nil { + t.Fatal(err) + } + ext := "json" + assert.Equal(t, filename, filepath.Join("/homedir", "c"+"."+ext)) +} + var yamlMergeExampleTgt = []byte(` hello: pop: 37890