diff --git a/opts/envfile_test.go b/opts/envfile_test.go index 6302263848..dd79f60925 100644 --- a/opts/envfile_test.go +++ b/opts/envfile_test.go @@ -139,3 +139,26 @@ another invalid line` t.Fatalf("Expected [%v], got [%v]", expectedMessage, err.Error()) } } + +// ParseEnvFile with environment variable import definitions +func TestParseEnvVariableDefinitionsFile(t *testing.T) { + content := `# comment= +UNDEFINED_VAR +HOME +` + tmpFile := tmpFileWithContent(content, t) + defer os.Remove(tmpFile) + + variables, err := ParseEnvFile(tmpFile) + if nil != err { + t.Fatal("There must not be any error") + } + + if "HOME="+os.Getenv("HOME") != variables[0] { + t.Fatal("the HOME variable is not properly imported as the first variable (but it is the only one to import)") + } + + if 1 != len(variables) { + t.Fatal("exactly one variable is imported (as the other one is not set at all)") + } +}