File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -114,11 +114,11 @@ func absPathify(inPath string) string {
114114 return ""
115115}
116116
117- // Check if File / Directory Exists
117+ // Check if file Exists
118118func exists (fs afero.Fs , path string ) (bool , error ) {
119- _ , err := fs .Stat (path )
119+ stat , err := fs .Stat (path )
120120 if err == nil {
121- return true , nil
121+ return ! stat . IsDir () , nil
122122 }
123123 if os .IsNotExist (err ) {
124124 return false , nil
Original file line number Diff line number Diff line change @@ -323,6 +323,26 @@ func TestSearchInPath(t *testing.T) {
323323 assert .NoError (t , err )
324324}
325325
326+ func TestSearchInPath_FilesOnly (t * testing.T ) {
327+ fs := afero .NewMemMapFs ()
328+
329+ err := fs .Mkdir ("/tmp/config" , 0777 )
330+ require .NoError (t , err )
331+
332+ _ , err = fs .Create ("/tmp/config/config.yaml" )
333+ require .NoError (t , err )
334+
335+ v := New ()
336+
337+ v .SetFs (fs )
338+ v .AddConfigPath ("/tmp" )
339+ v .AddConfigPath ("/tmp/config" )
340+
341+ filename , err := v .getConfigFile ()
342+ assert .Equal (t , "/tmp/config/config.yaml" , filename )
343+ assert .NoError (t , err )
344+ }
345+
326346func TestDefault (t * testing.T ) {
327347 SetDefault ("age" , 45 )
328348 assert .Equal (t , 45 , Get ("age" ))
You can’t perform that action at this time.
0 commit comments