From b91fd129966f4d84948cac5e690424eb14fbf0f1 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Mon, 2 Jul 2018 07:52:02 +0200 Subject: [PATCH] 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 --- opts/envfile_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/opts/envfile_test.go b/opts/envfile_test.go index dd79f60925..bda9dcb6e7 100644 --- a/opts/envfile_test.go +++ b/opts/envfile_test.go @@ -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") + } +}