mirror of
https://github.com/spf13/viper
synced 2024-12-23 12:07:02 +00:00
spf13/viper#73 Test to document no config in CWD when expected
This commit is contained in:
parent
c53a6dbc69
commit
5fa6a974f2
1 changed files with 18 additions and 0 deletions
|
@ -611,6 +611,24 @@ func TestCWDSearch(t *testing.T) {
|
||||||
assert.Equal(t, `root`, v.GetString(`key`))
|
assert.Equal(t, `root`, v.GetString(`key`))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCWDSearchNoConfig(t *testing.T) {
|
||||||
|
|
||||||
|
_, config, cleanup := initDirs(t)
|
||||||
|
defer cleanup()
|
||||||
|
|
||||||
|
// Remove the config file in CWD
|
||||||
|
os.Remove(config + ".toml")
|
||||||
|
|
||||||
|
v := New()
|
||||||
|
v.SetConfigName(config)
|
||||||
|
v.SetDefault(`key`, `default`)
|
||||||
|
|
||||||
|
err := v.ReadInConfig()
|
||||||
|
assert.Equal(t, reflect.TypeOf(UnsupportedConfigError("")), reflect.TypeOf(err))
|
||||||
|
|
||||||
|
assert.Equal(t, `default`, v.GetString(`key`))
|
||||||
|
}
|
||||||
|
|
||||||
func TestDirsSearch(t *testing.T) {
|
func TestDirsSearch(t *testing.T) {
|
||||||
|
|
||||||
root, config, cleanup := initDirs(t)
|
root, config, cleanup := initDirs(t)
|
||||||
|
|
Loading…
Reference in a new issue