Skip to content

Commit

Permalink
Merge branch 'master' into av-update-ports
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-video authored Sep 5, 2023
2 parents 08d9519 + 8bb2d49 commit 370be5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions common/readfromfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion common/readfromfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 370be5f

Please sign in to comment.