diff --git a/common/readfromfile.go b/common/readfromfile.go index cbfa82a178..c19c1bb37b 100644 --- a/common/readfromfile.go +++ b/common/readfromfile.go @@ -11,10 +11,9 @@ import ( // A valid string will always be returned, regardless of whether an error occurred. func ReadFromFile(s string) (string, error) { info, err := os.Stat(s) - if os.IsNotExist(err) { - // If the supplied string is not a path to a file, - // assume it is the pass and return it - return s, nil + // Return string as-is if the Stat call returned any error + if err != nil { + return s, err } if info.IsDir() { // If the supplied string is a directory, diff --git a/common/readfromfile_test.go b/common/readfromfile_test.go index b55dd4a7c9..b4a78d7dab 100644 --- a/common/readfromfile_test.go +++ b/common/readfromfile_test.go @@ -18,7 +18,7 @@ func TestReadFromFileNoFileExists(t *testing.T) { // ReadFromFile should return the string it was supplied output, err := ReadFromFile(input) - assert.Nil(err) + assert.NotNil(err) // ReadFromFile should return the originally supplied string assert.Equal(expectedOutput, output) }