mirror of https://github.com/docker/cli.git
add test for undefined variable environment file import
test to show current behavior is wrong at parsing an environment file defining an undefined variable - it must not be defined! NOTE: this test assume the $HOME variable is always set (see POSIX, this normally is the case, e.g. the test suite remains stable). Signed-off-by: Tom Klingenberg <tklingenberg@lastflood.net>
This commit is contained in:
parent
34ba66b0c5
commit
1e89745704
|
@ -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)")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue