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.
@@ -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")
+ }
+}
