add test for zero length variable name

parsing an environment file should give an error in case a zero-length
variable name (definition w/o a variable name) is encountered.

previously these lines went through unnoticed not informing the user about
a potential configuration error.

Signed-off-by: Tom Klingenberg <tklingenberg@lastflood.net>
This commit is contained in:
Tom Klingenberg 2018-07-02 07:52:02 +02:00
parent 96c026eb30
commit b91fd12996
1 changed files with 14 additions and 0 deletions

View File

@ -162,3 +162,17 @@ HOME
t.Fatal("exactly one variable is imported (as the other one is not set at all)")
}
}
// ParseEnvFile with empty variable name
func TestParseEnvVariableWithNoNameFile(t *testing.T) {
content := `# comment=
=blank variable names are an error case
`
tmpFile := tmpFileWithContent(content, t)
defer os.Remove(tmpFile)
_, err := ParseEnvFile(tmpFile)
if nil == err {
t.Fatal("if a variable has no name parsing an environment file must fail")
}
}