forked from coop-cloud-mirrors/godotenv
Propagate errors encountered when reading file
This commit is contained in:
parent
4ed13390c0
commit
0ff0c0fc7a
@ -143,6 +143,10 @@ func readFile(filename string) (envMap map[string]string, err error) {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
if err = scanner.Err(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, fullLine := range lines {
|
||||
if !isIgnoredLine(fullLine) {
|
||||
key, value, err := parseLine(fullLine)
|
||||
|
@ -269,3 +269,12 @@ func TestLinesToIgnore(t *testing.T) {
|
||||
t.Error("ignoring a perfectly valid line to parse")
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorReadDirectory(t *testing.T) {
|
||||
envFileName := "fixtures/"
|
||||
envMap, err := Read(envFileName)
|
||||
|
||||
if err == nil {
|
||||
t.Errorf("Expected error, got %v", envMap)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user