Skip to content

Commit be12d6c

Browse files
authored
Merge pull request #218 from kcboschert/inherit_undefined
Do not set undefined inherited variables
2 parents 5752093 + 2d60d49 commit be12d6c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

dotenv/godotenv_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ func TestInheritedEnvVariablSingleVar(t *testing.T) {
576576

577577
func TestInheritedEnvVariableNotFound(t *testing.T) {
578578
envMap, err := Read("fixtures/inherited-not-found.env")
579-
if envMap["VARIABLE_NOT_FOUND"] != "" || err != nil {
580-
t.Errorf("Expected 'VARIABLE_NOT_FOUND' to be '' with no errors")
579+
if _, ok := envMap["VARIABLE_NOT_FOUND"]; ok || err != nil {
580+
t.Errorf("Expected 'VARIABLE_NOT_FOUND' to be undefined with no errors")
581581
}
582582
}
583583

@@ -590,8 +590,8 @@ func TestInheritedEnvVariableNotFoundWithLookup(t *testing.T) {
590590
}
591591
return envVar, ok
592592
}, "fixtures/inherited-not-found.env")
593-
if envMap["VARIABLE_NOT_FOUND"] != "" || err != nil {
594-
t.Errorf("Expected 'VARIABLE_NOT_FOUND' to be '' with no errors")
593+
if _, ok := envMap["VARIABLE_NOT_FOUND"]; ok || err != nil {
594+
t.Errorf("Expected 'VARIABLE_NOT_FOUND' to be undefined with no errors")
595595
}
596596
_, ok := notFoundMap["VARIABLE_NOT_FOUND"]
597597
if !ok {

dotenv/parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ func parseBytes(src []byte, out map[string]string, lookupFn LookupFn) error {
4141
value, ok := lookupFn(key)
4242
if ok {
4343
out[key] = value
44-
cutset = left
45-
continue
4644
}
45+
cutset = left
46+
continue
4747
}
4848

4949
value, left, err := extractVarValue(left, out, lookupFn)

0 commit comments

Comments
 (0)