Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Return an error when the file could not be found on disk
Browse files Browse the repository at this point in the history
  • Loading branch information
nstapelbroek committed Jul 8, 2018
1 parent 66717a0 commit 7137e14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/BurntSushi/toml"
"github.com/containous/flaeg"
"fmt"
)

var _ Source = (*TomlSource)(nil)
Expand Down Expand Up @@ -34,7 +35,7 @@ func (ts *TomlSource) ConfigFileUsed() string {
func (ts *TomlSource) Parse(cmd *flaeg.Command) (*flaeg.Command, error) {
ts.fullPath = findFile(ts.filename, ts.dirNFullPath)
if len(ts.fullPath) < 2 {
return cmd, nil
return cmd, fmt.Errorf("unable to find config file %s", ts.filename)
}

metadata, err := toml.DecodeFile(ts.fullPath, cmd.Config)
Expand Down
2 changes: 1 addition & 1 deletion toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func TestTomlSource_Parse_FileNotFound(t *testing.T) {
}

command, err := src.Parse(cmd)
require.NoError(t, err)

assert.Error(t, err, "unable to find config file")
assert.Exactly(t, cmd, command)
}

Expand Down

0 comments on commit 7137e14

Please sign in to comment.